-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7855 from hashicorp/b-ui/alloc-wrong-reserved-res…
…ources UI: Make allocation reference own task group instead of job's task group when job versions don't match
- Loading branch information
Showing
8 changed files
with
218 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { run } from '@ember/runloop'; | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
module('Unit | Model | allocation', function(hooks) { | ||
setupTest(hooks); | ||
hooks.beforeEach(function() { | ||
this.store = this.owner.lookup('service:store'); | ||
}); | ||
|
||
test("When the allocation's job version matches the job's version, the task group comes from the job.", function(assert) { | ||
const job = run(() => | ||
this.store.createRecord('job', { | ||
name: 'this-job', | ||
version: 1, | ||
taskGroups: [ | ||
{ | ||
name: 'from-job', | ||
count: 1, | ||
task: [], | ||
}, | ||
], | ||
}) | ||
); | ||
|
||
const allocation = run(() => | ||
this.store.createRecord('allocation', { | ||
job, | ||
jobVersion: 1, | ||
taskGroupName: 'from-job', | ||
allocationTaskGroup: { | ||
name: 'from-allocation', | ||
count: 1, | ||
task: [], | ||
}, | ||
}) | ||
); | ||
|
||
assert.equal(allocation.get('taskGroup.name'), 'from-job'); | ||
}); | ||
|
||
test("When the allocation's job version does not match the job's version, the task group comes from the alloc.", function(assert) { | ||
const job = run(() => | ||
this.store.createRecord('job', { | ||
name: 'this-job', | ||
version: 1, | ||
taskGroups: [ | ||
{ | ||
name: 'from-job', | ||
count: 1, | ||
task: [], | ||
}, | ||
], | ||
}) | ||
); | ||
|
||
const allocation = run(() => | ||
this.store.createRecord('allocation', { | ||
job, | ||
jobVersion: 2, | ||
taskGroupName: 'from-job', | ||
allocationTaskGroup: { | ||
name: 'from-allocation', | ||
count: 1, | ||
task: [], | ||
}, | ||
}) | ||
); | ||
|
||
assert.equal(allocation.get('taskGroup.name'), 'from-allocation'); | ||
}); | ||
|
||
test("When the allocation's job version does not match the job's version and the allocation has no task group, then task group is null", async function(assert) { | ||
const job = run(() => | ||
this.store.createRecord('job', { | ||
name: 'this-job', | ||
version: 1, | ||
taskGroups: [ | ||
{ | ||
name: 'from-job', | ||
count: 1, | ||
task: [], | ||
}, | ||
], | ||
}) | ||
); | ||
|
||
const allocation = run(() => | ||
this.store.createRecord('allocation', { | ||
job, | ||
jobVersion: 2, | ||
taskGroupName: 'from-job', | ||
}) | ||
); | ||
|
||
assert.equal(allocation.get('taskGroup.name'), null); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters