test(web): share the id of another pool between the tests

This commit is contained in:
Olivier Floch
2026-11-09 09:12:36 +01:00
parent d85415f28e
commit cdda6f6e2a
5 changed files with 8 additions and 9 deletions

View File

@@ -7,7 +7,7 @@ Domain objects are created through factories in `src/test/`, one per object type
| `createVm` | `FrontXoVm` |
| `createHost` | `FrontXoHost` |
| `createServer` | `FrontXoServer` |
| `createPool` | `FrontXoPool` |
| `createPool`, `OTHER_POOL_ID` | `FrontXoPool`, the id of a pool other than `createPool()`'s |
| `createSr` | `FrontXoSr` |
| `createVbd` | `FrontXoVbd` |
| `createVdi` | `FrontXoVdi` |

View File

@@ -2,6 +2,7 @@ import type { FrontXoPool } from '@/modules/pool/remote-resources/use-xo-pool-co
import { useV2vMigrationList } from '@/modules/v2v/composables/use-v2v-migration-list.composable.ts'
import type { V2vMigrationList } from '@/modules/v2v/types/v2v-migration-list.type.ts'
import { getV2vMigrationListStorageKey } from '@/modules/v2v/utils/v2v-migration-list.util.ts'
import { OTHER_POOL_ID } from '@/test/create-pool.ts'
import {
createV2vDestinationDefaults,
createV2vMigrationList,
@@ -17,8 +18,6 @@ const STORED_LIST = createV2vMigrationList({ vms: createV2vMigrationListVms(2) }
const { sourceId: SOURCE_ID, poolId: POOL_ID } = STORED_LIST
const OTHER_POOL_ID = 'pool-2' as FrontXoPool['id']
const NEW_DEFAULTS = createV2vDestinationDefaults({
template: 'template-2' as V2vMigrationList['defaults']['template'],
})

View File

@@ -8,7 +8,7 @@ import { chooseCompleteV2vDestination, chooseV2vDestinationPool } from '@/test/c
import { createHost } from '@/test/create-host.ts'
import { createNetwork } from '@/test/create-network.ts'
import { createManagementPif } from '@/test/create-pif.ts'
import { createPool } from '@/test/create-pool.ts'
import { createPool, OTHER_POOL_ID } from '@/test/create-pool.ts'
import { createSr } from '@/test/create-sr.ts'
import { createV2vDestinationDefaults, createV2vMigrationList } from '@/test/create-v2v-migration-list.ts'
import { createVmTemplate } from '@/test/create-vm-template.ts'
@@ -55,7 +55,7 @@ vi.mock(
const POOL = createPool()
const OTHER_POOL = createPool({
id: 'pool-2' as FrontXoPool['id'],
id: OTHER_POOL_ID,
master: 'host-2' as FrontXoPool['master'],
default_SR: 'sr-2' as FrontXoPool['default_SR'],
})

View File

@@ -1,6 +1,5 @@
import type { FrontXoHost } from '@/modules/host/remote-resources/use-xo-host-collection.ts'
import type { FrontXoNetwork } from '@/modules/network/remote-resources/use-xo-network-collection.ts'
import type { FrontXoPool } from '@/modules/pool/remote-resources/use-xo-pool-collection.ts'
import type { FrontXoSr } from '@/modules/storage-repository/remote-resources/use-xo-sr-collection.ts'
import {
countV2vPoolResources,
@@ -12,15 +11,13 @@ import {
import { createHost } from '@/test/create-host.ts'
import { createNetwork } from '@/test/create-network.ts'
import { createManagementPif, createPif } from '@/test/create-pif.ts'
import { createPool } from '@/test/create-pool.ts'
import { createPool, OTHER_POOL_ID } from '@/test/create-pool.ts'
import { createSr } from '@/test/create-sr.ts'
import { createV2vMigrationList } from '@/test/create-v2v-migration-list.ts'
import { createVmTemplate } from '@/test/create-vm-template.ts'
const POOL = createPool()
const OTHER_POOL_ID = 'pool-2' as FrontXoPool['id']
const MANAGEMENT_NETWORK_ID = 'network-mgmt' as FrontXoNetwork['id']
const MANAGEMENT_PIF = createManagementPif(POOL, MANAGEMENT_NETWORK_ID)

View File

@@ -4,6 +4,9 @@ import type { FrontXoPool } from '@/modules/pool/remote-resources/use-xo-pool-co
* Builds a fully-populated `FrontXoPool` for use in tests. Pass `overrides` to
* tweak only the fields relevant to the case under test.
*/
// A pool id distinct from the `createPool()` one, for the resources of another pool
export const OTHER_POOL_ID = 'pool-2' as FrontXoPool['id']
export function createPool(overrides: Partial<FrontXoPool> = {}): FrontXoPool {
return {
id: 'pool-789' as FrontXoPool['id'],