Updated serializer unit tests

This commit is contained in:
Michael Lange 2019-04-22 17:20:52 -07:00
parent 35e34fea8b
commit f530c2f5c1
2 changed files with 140 additions and 2 deletions

View File

@ -44,6 +44,7 @@ module('Unit | Serializer | Allocation', function(hooks) {
failed: false, failed: false,
}, },
], ],
wasPreempted: false,
}, },
relationships: { relationships: {
followUpEvaluation: { followUpEvaluation: {
@ -55,6 +56,12 @@ module('Unit | Serializer | Allocation', function(hooks) {
previousAllocation: { previousAllocation: {
data: null, data: null,
}, },
preemptedAllocations: {
data: [],
},
preemptedByAllocation: {
data: null,
},
job: { job: {
data: { data: {
id: '["test-summary","test-namespace"]', id: '["test-summary","test-namespace"]',
@ -108,6 +115,7 @@ module('Unit | Serializer | Allocation', function(hooks) {
failed: true, failed: true,
}, },
], ],
wasPreempted: false,
}, },
relationships: { relationships: {
followUpEvaluation: { followUpEvaluation: {
@ -119,6 +127,82 @@ module('Unit | Serializer | Allocation', function(hooks) {
previousAllocation: { previousAllocation: {
data: null, data: null,
}, },
preemptedAllocations: {
data: [],
},
preemptedByAllocation: {
data: null,
},
job: {
data: {
id: '["test-summary","test-namespace"]',
type: 'job',
},
},
},
},
},
},
{
name: 'With preemptions',
in: {
ID: 'test-allocation',
JobID: 'test-summary',
Name: 'test-summary[1]',
Namespace: 'test-namespace',
TaskGroup: 'test-group',
CreateTime: +sampleDate * 1000000,
ModifyTime: +sampleDate * 1000000,
TaskStates: {
task: {
State: 'running',
Failed: false,
},
},
PreemptedByAllocation: 'preempter-allocation',
PreemptedAllocations: ['preempted-one-allocation', 'preempted-two-allocation'],
},
out: {
data: {
id: 'test-allocation',
type: 'allocation',
attributes: {
taskGroupName: 'test-group',
name: 'test-summary[1]',
modifyTime: sampleDate,
createTime: sampleDate,
states: [
{
name: 'task',
state: 'running',
failed: false,
},
],
wasPreempted: true,
},
relationships: {
followUpEvaluation: {
data: null,
},
nextAllocation: {
data: null,
},
previousAllocation: {
data: null,
},
preemptedAllocations: {
data: [
{ id: 'preempted-one-allocation', type: 'allocation' },
{ id: 'preempted-two-allocation', type: 'allocation' },
],
},
preemptedByAllocation: {
data: {
id: 'preempter-allocation',
type: 'allocation',
},
},
job: { job: {
data: { data: {
id: '["test-summary","test-namespace"]', id: '["test-summary","test-namespace"]',

View File

@ -38,7 +38,11 @@ module('Unit | Serializer | JobPlan', function(hooks) {
}, },
], ],
}, },
relationships: {}, relationships: {
preemptions: {
data: [],
},
},
}, },
}, },
}, },
@ -78,7 +82,57 @@ module('Unit | Serializer | JobPlan', function(hooks) {
}, },
], ],
}, },
relationships: {}, relationships: {
preemptions: {
data: [],
},
},
},
},
},
{
name: 'With preemptions',
in: {
ID: 'test-plan',
Diff: {
Arbitrary: 'Value',
},
FailedTGAllocs: {
task: {
NodesAvailable: 10,
},
},
Annotations: {
PreemptedAllocs: [
{ ID: 'preemption-one-allocation' },
{ ID: 'preemption-two-allocation' },
],
},
},
out: {
data: {
id: 'test-plan',
type: 'job-plan',
attributes: {
diff: {
Arbitrary: 'Value',
},
failedTGAllocs: [
{
name: 'task',
nodesAvailable: 10,
},
],
},
relationships: {
preemptions: {
data: [
{ id: 'preemption-one-allocation', type: 'allocation' },
{ id: 'preemption-two-allocation', type: 'allocation' },
],
},
},
}, },
}, },
}, },