github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/tests/unit/serializers/deployment-test.js (about) 1 import { module, test } from 'qunit'; 2 import { setupTest } from 'ember-qunit'; 3 import DeploymentModel from 'nomad-ui/models/deployment'; 4 5 module('Unit | Serializer | Deployment', function(hooks) { 6 setupTest(hooks); 7 hooks.beforeEach(function() { 8 this.store = this.owner.lookup('service:store'); 9 this.subject = () => this.store.serializerFor('deployment'); 10 }); 11 12 const normalizationTestCases = [ 13 { 14 name: 'Normal', 15 in: { 16 ID: 'test-deployment', 17 JobID: 'test-job', 18 Namespace: 'test-namespace', 19 Status: 'canceled', 20 TaskGroups: { 21 taskGroup: { 22 DesiredCanaries: 2, 23 }, 24 }, 25 }, 26 out: { 27 data: { 28 id: 'test-deployment', 29 type: 'deployment', 30 attributes: { 31 status: 'canceled', 32 taskGroupSummaries: [ 33 { 34 name: 'taskGroup', 35 desiredCanaries: 2, 36 placedCanaryAllocations: [], 37 }, 38 ], 39 }, 40 relationships: { 41 allocations: { 42 links: { 43 related: '/v1/deployment/allocations/test-deployment', 44 }, 45 }, 46 job: { 47 data: { 48 id: '["test-job","test-namespace"]', 49 type: 'job', 50 }, 51 }, 52 jobForLatest: { 53 data: { 54 id: '["test-job","test-namespace"]', 55 type: 'job', 56 }, 57 }, 58 }, 59 }, 60 }, 61 }, 62 63 { 64 name: 'Dots in task group names', 65 in: { 66 ID: 'test-deployment', 67 JobID: 'test-job', 68 Namespace: 'test-namespace', 69 Status: 'canceled', 70 TaskGroups: { 71 'one.two': { 72 DesiredCanaries: 2, 73 }, 74 'three.four': { 75 DesiredCanaries: 3, 76 }, 77 }, 78 }, 79 out: { 80 data: { 81 id: 'test-deployment', 82 type: 'deployment', 83 attributes: { 84 status: 'canceled', 85 taskGroupSummaries: [ 86 { 87 name: 'one.two', 88 desiredCanaries: 2, 89 placedCanaryAllocations: [], 90 }, 91 { 92 name: 'three.four', 93 desiredCanaries: 3, 94 placedCanaryAllocations: [], 95 }, 96 ], 97 }, 98 relationships: { 99 allocations: { 100 links: { 101 related: '/v1/deployment/allocations/test-deployment', 102 }, 103 }, 104 job: { 105 data: { 106 id: '["test-job","test-namespace"]', 107 type: 'job', 108 }, 109 }, 110 jobForLatest: { 111 data: { 112 id: '["test-job","test-namespace"]', 113 type: 'job', 114 }, 115 }, 116 }, 117 }, 118 }, 119 }, 120 ]; 121 122 normalizationTestCases.forEach(testCase => { 123 test(`normalization: ${testCase.name}`, async function(assert) { 124 assert.deepEqual(this.subject().normalize(DeploymentModel, testCase.in), testCase.out); 125 }); 126 }); 127 });