2019-03-14 02:17:12 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupTest } from 'ember-qunit';
|
2018-12-13 00:49:52 +00:00
|
|
|
import DeploymentModel from 'nomad-ui/models/deployment';
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
module('Unit | Serializer | Deployment', function (hooks) {
|
2019-03-14 02:17:12 +00:00
|
|
|
setupTest(hooks);
|
2021-12-28 14:45:20 +00:00
|
|
|
hooks.beforeEach(function () {
|
2019-03-14 02:17:12 +00:00
|
|
|
this.store = this.owner.lookup('service:store');
|
|
|
|
this.subject = () => this.store.serializerFor('deployment');
|
|
|
|
});
|
2018-12-13 00:49:52 +00:00
|
|
|
|
2019-03-14 02:17:12 +00:00
|
|
|
const normalizationTestCases = [
|
|
|
|
{
|
|
|
|
name: 'Normal',
|
|
|
|
in: {
|
|
|
|
ID: 'test-deployment',
|
|
|
|
JobID: 'test-job',
|
|
|
|
Namespace: 'test-namespace',
|
|
|
|
Status: 'canceled',
|
|
|
|
TaskGroups: {
|
|
|
|
taskGroup: {
|
|
|
|
DesiredCanaries: 2,
|
|
|
|
},
|
2018-12-13 00:49:52 +00:00
|
|
|
},
|
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
out: {
|
|
|
|
data: {
|
|
|
|
id: 'test-deployment',
|
|
|
|
type: 'deployment',
|
|
|
|
attributes: {
|
|
|
|
status: 'canceled',
|
|
|
|
taskGroupSummaries: [
|
|
|
|
{
|
|
|
|
name: 'taskGroup',
|
|
|
|
desiredCanaries: 2,
|
|
|
|
placedCanaryAllocations: [],
|
|
|
|
},
|
|
|
|
],
|
2018-12-13 00:49:52 +00:00
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
relationships: {
|
|
|
|
allocations: {
|
|
|
|
links: {
|
|
|
|
related: '/v1/deployment/allocations/test-deployment',
|
|
|
|
},
|
2018-12-13 00:49:52 +00:00
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
job: {
|
|
|
|
data: {
|
|
|
|
id: '["test-job","test-namespace"]',
|
|
|
|
type: 'job',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
jobForLatest: {
|
|
|
|
data: {
|
|
|
|
id: '["test-job","test-namespace"]',
|
|
|
|
type: 'job',
|
|
|
|
},
|
2018-12-13 00:49:52 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-03-14 02:17:12 +00:00
|
|
|
{
|
|
|
|
name: 'Dots in task group names',
|
|
|
|
in: {
|
|
|
|
ID: 'test-deployment',
|
|
|
|
JobID: 'test-job',
|
|
|
|
Namespace: 'test-namespace',
|
|
|
|
Status: 'canceled',
|
|
|
|
TaskGroups: {
|
|
|
|
'one.two': {
|
|
|
|
DesiredCanaries: 2,
|
|
|
|
},
|
|
|
|
'three.four': {
|
|
|
|
DesiredCanaries: 3,
|
|
|
|
},
|
2018-12-13 00:49:52 +00:00
|
|
|
},
|
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
out: {
|
|
|
|
data: {
|
|
|
|
id: 'test-deployment',
|
|
|
|
type: 'deployment',
|
|
|
|
attributes: {
|
|
|
|
status: 'canceled',
|
|
|
|
taskGroupSummaries: [
|
|
|
|
{
|
|
|
|
name: 'one.two',
|
|
|
|
desiredCanaries: 2,
|
|
|
|
placedCanaryAllocations: [],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'three.four',
|
|
|
|
desiredCanaries: 3,
|
|
|
|
placedCanaryAllocations: [],
|
|
|
|
},
|
|
|
|
],
|
2018-12-13 00:49:52 +00:00
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
relationships: {
|
|
|
|
allocations: {
|
|
|
|
links: {
|
|
|
|
related: '/v1/deployment/allocations/test-deployment',
|
|
|
|
},
|
2018-12-13 00:49:52 +00:00
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
job: {
|
|
|
|
data: {
|
|
|
|
id: '["test-job","test-namespace"]',
|
|
|
|
type: 'job',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
jobForLatest: {
|
|
|
|
data: {
|
|
|
|
id: '["test-job","test-namespace"]',
|
|
|
|
type: 'job',
|
|
|
|
},
|
2018-12-13 00:49:52 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
];
|
2018-12-13 00:49:52 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
normalizationTestCases.forEach((testCase) => {
|
|
|
|
test(`normalization: ${testCase.name}`, async function (assert) {
|
2019-03-14 02:17:12 +00:00
|
|
|
assert.deepEqual(this.subject().normalize(DeploymentModel, testCase.in), testCase.out);
|
|
|
|
});
|
2018-12-13 00:49:52 +00:00
|
|
|
});
|
|
|
|
});
|