2020-12-07 20:28:47 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupTest } from 'ember-qunit';
|
|
|
|
import ScaleEventModel from 'nomad-ui/models/scale-event';
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
module('Unit | Serializer | Scale Event', function (hooks) {
|
2020-12-07 20:28:47 +00:00
|
|
|
setupTest(hooks);
|
2021-12-28 14:45:20 +00:00
|
|
|
hooks.beforeEach(function () {
|
2020-12-07 20:28:47 +00:00
|
|
|
this.store = this.owner.lookup('service:store');
|
|
|
|
this.subject = () => this.store.serializerFor('scale-event');
|
|
|
|
});
|
|
|
|
|
|
|
|
const sampleDate = new Date('2020-12-07T00:00:00');
|
|
|
|
const normalizationTestCases = [
|
|
|
|
{
|
|
|
|
name: 'Normal',
|
|
|
|
in: {
|
|
|
|
Count: null,
|
|
|
|
CreateIndex: 16,
|
|
|
|
Error: true,
|
|
|
|
EvalID: null,
|
|
|
|
Message: 'job scaling blocked due to active deployment',
|
|
|
|
Meta: {
|
|
|
|
OriginalCount: 3,
|
|
|
|
OriginalMessage: 'submitted using the Nomad CLI',
|
|
|
|
OriginalMeta: null,
|
|
|
|
},
|
|
|
|
PreviousCount: 1,
|
|
|
|
Time: +sampleDate * 1000000,
|
|
|
|
},
|
|
|
|
out: {
|
|
|
|
data: {
|
|
|
|
attributes: {
|
|
|
|
count: null,
|
|
|
|
error: true,
|
|
|
|
message: 'job scaling blocked due to active deployment',
|
|
|
|
meta: {
|
|
|
|
OriginalCount: 3,
|
|
|
|
OriginalMessage: 'submitted using the Nomad CLI',
|
|
|
|
OriginalMeta: null,
|
|
|
|
},
|
|
|
|
previousCount: 1,
|
|
|
|
time: sampleDate,
|
|
|
|
timeNanos: 0,
|
|
|
|
},
|
|
|
|
relationships: {},
|
|
|
|
type: 'scale-event',
|
|
|
|
id: null,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'No meta',
|
|
|
|
in: {
|
|
|
|
Count: 3,
|
|
|
|
CreateIndex: 23,
|
|
|
|
Error: false,
|
|
|
|
EvalID: '753bb12c-345e-22b2-f0b4-17f84239b98b',
|
|
|
|
Message: 'submitted using the Nomad CLI',
|
|
|
|
Meta: null,
|
|
|
|
PreviousCount: 1,
|
|
|
|
Time: +sampleDate * 1000000,
|
|
|
|
},
|
|
|
|
out: {
|
|
|
|
data: {
|
|
|
|
attributes: {
|
|
|
|
count: 3,
|
|
|
|
error: false,
|
|
|
|
message: 'submitted using the Nomad CLI',
|
|
|
|
meta: {},
|
|
|
|
previousCount: 1,
|
|
|
|
time: sampleDate,
|
|
|
|
timeNanos: 0,
|
|
|
|
},
|
|
|
|
relationships: {},
|
|
|
|
type: 'scale-event',
|
|
|
|
id: null,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
normalizationTestCases.forEach((testCase) => {
|
|
|
|
test(`normalization: ${testCase.name}`, async function (assert) {
|
2021-12-28 16:08:12 +00:00
|
|
|
assert.deepEqual(
|
|
|
|
this.subject().normalize(ScaleEventModel, testCase.in),
|
|
|
|
testCase.out
|
|
|
|
);
|
2020-12-07 20:28:47 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|