2019-03-14 02:17:12 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupTest } from 'ember-qunit';
|
2018-12-13 00:07:56 +00:00
|
|
|
import EvaluationModel from 'nomad-ui/models/evaluation';
|
|
|
|
|
2019-03-14 02:17:12 +00:00
|
|
|
module('Unit | Serializer | Evaluation', function(hooks) {
|
|
|
|
setupTest(hooks);
|
|
|
|
hooks.beforeEach(function() {
|
|
|
|
this.store = this.owner.lookup('service:store');
|
|
|
|
this.subject = () => this.store.serializerFor('evaluation');
|
|
|
|
});
|
2018-12-13 00:07:56 +00:00
|
|
|
|
2019-03-14 02:17:12 +00:00
|
|
|
const normalizationTestCases = [
|
|
|
|
{
|
|
|
|
name: 'Normal',
|
|
|
|
in: {
|
|
|
|
ID: 'test-eval',
|
|
|
|
FailedTGAllocs: {
|
|
|
|
taskGroup: {
|
|
|
|
NodesAvailable: 10,
|
|
|
|
},
|
2018-12-13 00:07:56 +00:00
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
JobID: 'some-job-id',
|
|
|
|
Job: {
|
|
|
|
Namespace: 'test-namespace',
|
2018-12-13 00:07:56 +00:00
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
},
|
|
|
|
out: {
|
|
|
|
data: {
|
|
|
|
id: 'test-eval',
|
|
|
|
type: 'evaluation',
|
|
|
|
attributes: {
|
|
|
|
failedTGAllocs: [
|
|
|
|
{
|
|
|
|
name: 'taskGroup',
|
|
|
|
nodesAvailable: 10,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
relationships: {
|
|
|
|
job: {
|
|
|
|
data: {
|
|
|
|
id: '["some-job-id","test-namespace"]',
|
|
|
|
type: 'job',
|
|
|
|
},
|
2018-12-13 00:07:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-03-14 02:17:12 +00:00
|
|
|
{
|
|
|
|
name: 'Dots in task group names',
|
|
|
|
in: {
|
|
|
|
ID: 'test-eval',
|
|
|
|
FailedTGAllocs: {
|
|
|
|
'one.two': {
|
|
|
|
NodesAvailable: 10,
|
|
|
|
},
|
|
|
|
'three.four': {
|
|
|
|
NodesAvailable: 25,
|
|
|
|
},
|
2018-12-13 00:07:56 +00:00
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
JobID: 'some-job-id',
|
|
|
|
Job: {
|
|
|
|
Namespace: 'test-namespace',
|
2018-12-13 00:07:56 +00:00
|
|
|
},
|
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
out: {
|
|
|
|
data: {
|
|
|
|
id: 'test-eval',
|
|
|
|
type: 'evaluation',
|
|
|
|
attributes: {
|
|
|
|
failedTGAllocs: [
|
|
|
|
{
|
|
|
|
name: 'one.two',
|
|
|
|
nodesAvailable: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'three.four',
|
|
|
|
nodesAvailable: 25,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
relationships: {
|
|
|
|
job: {
|
|
|
|
data: {
|
|
|
|
id: '["some-job-id","test-namespace"]',
|
|
|
|
type: 'job',
|
|
|
|
},
|
2018-12-13 00:07:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-03-14 02:17:12 +00:00
|
|
|
];
|
2018-12-13 00:07:56 +00:00
|
|
|
|
2019-03-14 02:17:12 +00:00
|
|
|
normalizationTestCases.forEach(testCase => {
|
2019-03-14 18:35:46 +00:00
|
|
|
test(`normalization: ${testCase.name}`, async function(assert) {
|
2019-03-14 02:17:12 +00:00
|
|
|
assert.deepEqual(this.subject().normalize(EvaluationModel, testCase.in), testCase.out);
|
|
|
|
});
|
2018-12-13 00:07:56 +00:00
|
|
|
});
|
|
|
|
});
|