Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
Add tests for resolving migration plan POST body from redux state
Browse files Browse the repository at this point in the history
  • Loading branch information
mturley committed Dec 7, 2018
1 parent ee80fcf commit 8a14c80
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 0 deletions.
@@ -0,0 +1,59 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`createMigrationPlans with a RHV target and playbooks 1`] = `
Object {
"config_info": Object {
"actions": Array [
Object {
"osp_flavor_id": undefined,
"osp_security_group_id": undefined,
"post_service": false,
"pre_service": true,
"vm_id": "28",
},
Object {
"osp_flavor_id": undefined,
"osp_security_group_id": undefined,
"post_service": true,
"pre_service": false,
"vm_id": "36",
},
],
"post_service_id": "2",
"pre_service_id": "1",
"transformation_mapping_id": "1",
},
"description": "",
"name": "test RHV w/ playbooks",
"prov_type": "generic_transformation_plan",
}
`;

exports[`createMigrationPlans with an OSP target 1`] = `
Object {
"config_info": Object {
"actions": Array [
Object {
"osp_flavor_id": "42000000000004",
"osp_security_group_id": "42000000000016",
"post_service": false,
"pre_service": false,
"vm_id": "42000000000017",
},
Object {
"osp_flavor_id": "42000000000002",
"osp_security_group_id": "42000000000022",
"post_service": false,
"pre_service": false,
"vm_id": "42000000000006",
},
],
"post_service_id": "",
"pre_service_id": "",
"transformation_mapping_id": "42000000000002",
},
"description": "",
"name": "test OSP plan",
"prov_type": "generic_transformation_plan",
}
`;
@@ -0,0 +1,36 @@
import { createMigrationPlans } from '../helpers';
import { ospPlanReduxFormState, rhvPlanReduxFormState } from '../planWizard.fixtures';

describe('createMigrationPlans', () => {
test('with an OSP target', () => {
const {
planWizardGeneralStep,
planWizardVMStep,
planWizardInstancePropertiesStep,
planWizardAdvancedOptionsStep
} = ospPlanReduxFormState;
const plansBody = createMigrationPlans(
planWizardGeneralStep,
planWizardVMStep,
planWizardInstancePropertiesStep,
planWizardAdvancedOptionsStep
);
expect(plansBody).toMatchSnapshot();
});

test('with a RHV target and playbooks', () => {
const {
planWizardGeneralStep,
planWizardVMStep,
planWizardInstancePropertiesStep,
planWizardAdvancedOptionsStep
} = rhvPlanReduxFormState;
const plansBody = createMigrationPlans(
planWizardGeneralStep,
planWizardVMStep,
planWizardInstancePropertiesStep,
planWizardAdvancedOptionsStep
);
expect(plansBody).toMatchSnapshot();
});
});
@@ -0,0 +1,105 @@
export const ospPlanReduxFormState = {
planWizardGeneralStep: {
registeredFields: {
infrastructure_mapping: { name: 'infrastructure_mapping', type: 'Field', count: 0 },
name: { name: 'name', type: 'Field', count: 0 },
description: { name: 'description', type: 'Field', count: 0 },
vm_choice_radio: { name: 'vm_choice_radio', type: 'Field', count: 0 }
},
values: {
infrastructure_mapping: '42000000000002',
vm_choice_radio: 'vms_via_discovery',
name: 'test OSP plan',
description: ''
},
initial: { infrastructure_mapping: null, vm_choice_radio: 'vms_via_discovery', name: '', description: '' },
fields: {
infrastructure_mapping: { visited: true },
name: { visited: true, touched: true },
description: { visited: true, touched: true }
},
anyTouched: true
},
planWizardVMStep: {
registeredFields: { selectedVms: { name: 'selectedVms', type: 'Field', count: 0 } },
values: { selectedVms: ['42000000000017', '42000000000006'] },
initial: { selectedVms: [] }
},
planWizardInstancePropertiesStep: {
values: {
instancePropertiesVms: {
rows: {
'42000000000017': { osp_security_group_id: '42000000000016', osp_flavor_id: '42000000000004' },
'42000000000006': { osp_security_group_id: '42000000000022', osp_flavor_id: '42000000000002' }
},
updatedInstancePropertiesRowOnStandby: {}
}
},
initial: { instancePropertiesVms: { updatedInstancePropertiesRowOnStandby: {} } },
registeredFields: { instancePropertiesVms: { name: 'instancePropertiesVms', type: 'Field', count: 0 } }
},
planWizardAdvancedOptionsStep: {
values: {
playbookVms: { preMigration: [], postMigration: [] },
preMigrationPlaybook: '',
postMigrationPlaybook: ''
},
initial: {
playbookVms: { preMigration: [], postMigration: [] },
preMigrationPlaybook: '',
postMigrationPlaybook: ''
},
registeredFields: {
preMigrationPlaybook: { name: 'preMigrationPlaybook', type: 'Field', count: 0 },
postMigrationPlaybook: { name: 'postMigrationPlaybook', type: 'Field', count: 0 },
playbookVms: { name: 'playbookVms', type: 'Field', count: 0 }
}
}
};

export const rhvPlanReduxFormState = {
planWizardGeneralStep: {
values: {
infrastructure_mapping: '1',
vm_choice_radio: 'vms_via_discovery',
name: 'test RHV w/ playbooks',
description: ''
},
initial: { infrastructure_mapping: null, vm_choice_radio: 'vms_via_discovery', name: '', description: '' },
registeredFields: {
infrastructure_mapping: { name: 'infrastructure_mapping', type: 'Field', count: 0 },
name: { name: 'name', type: 'Field', count: 0 },
description: { name: 'description', type: 'Field', count: 0 },
vm_choice_radio: { name: 'vm_choice_radio', type: 'Field', count: 0 }
},
fields: {
infrastructure_mapping: { visited: true },
name: { visited: true, touched: true },
description: { visited: true, touched: true }
},
anyTouched: true
},
planWizardVMStep: {
values: { selectedVms: ['28', '36'] },
initial: { selectedVms: [] },
registeredFields: { selectedVms: { name: 'selectedVms', type: 'Field', count: 0 } }
},
planWizardInstancePropertiesStep: {},
planWizardAdvancedOptionsStep: {
values: {
playbookVms: { preMigration: ['28'], postMigration: ['36'] },
preMigrationPlaybook: '1',
postMigrationPlaybook: '2'
},
initial: {
playbookVms: { preMigration: [], postMigration: [] },
preMigrationPlaybook: '',
postMigrationPlaybook: ''
},
registeredFields: {
preMigrationPlaybook: { name: 'preMigrationPlaybook', type: 'Field', count: 0 },
postMigrationPlaybook: { name: 'postMigrationPlaybook', type: 'Field', count: 0 },
playbookVms: { name: 'playbookVms', type: 'Field', count: 0 }
}
}
};

0 comments on commit 8a14c80

Please sign in to comment.