feat: 🎸 Add worker serializer (#1230)
* feat: 🎸 Add worker serializer Add worker serializer that focus' on `config_tags.type` and `canonical_tags.type`. [API](https://docs.google.com/document/d/1G-lfl8gk9NfoKFImSpHb90E3xC3CSEVDwVy3bJ9eOhA/edit#heading=h.9e06o4b8etpi) ✅ Closes: ICU-5241 * refactor: 💡 refactored `models/worker.js` Because `canonical_tags` and `config_tags` are `readOnly` attributes, we could use `attr` decorator instead of `fragment`. ✅ Closes: ICU-5241 * refactored `model/worker.js and deleted un-needed files * refactor: 💡 Refactored model/worker.js and created test Refactored model/worker.js to include custom method for POST route for adding new worker. BREAKING CHANGE: 🧨 no ✅ Closes: ICU-5241 * refactor: 💡 Refactored custom POST route method for worker Refactored custom method on `model/worker.js` to include serialization for `worker_genrated_auth_token` BREAKING CHANGE: 🧨 no ✅ Closes: ICU-5241 * refactor: 💡 Refactor test Refactor model/worker-test.js and serializers/worker.js BREAKING CHANGE: 🧨 no ✅ Closes: ICU-5241 * Update addons/api/addon/serializers/worker.js Co-authored-by: Dharini Jeeva <dharini@hashicorp.com> * update worker.js documentation block Co-authored-by: Dharini Jeeva <dharini@hashicorp.com>
This commit is contained in:
1 parent
1f0baceb5e
commit
62077d3c25
8 files changed
+117
-39
No files matched your search
@@ -1,13 +0,0 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Model | fragment tag', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function (assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('fragment-tag', {});
|
||||
assert.ok(model);
|
||||
});
|
||||
});
|
||||
@@ -1,13 +1,25 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
|
||||
module('Unit | Model | worker', function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function (assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('worker', {});
|
||||
assert.ok(model);
|
||||
test('it has an `addWorkerLed` method that targets a specific POST API', async function (assert) {
|
||||
assert.expect(2);
|
||||
this.server.post('/v1/workers:create:worker-led', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
worker_generated_auth_token: 'token',
|
||||
});
|
||||
return { id: '123abc' };
|
||||
});
|
||||
|
||||
const store = this.owner.lookup('service:store');
|
||||
const model = store.createRecord('worker', { type: 'pki' });
|
||||
await model.addWorkerLed('token');
|
||||
const worker = store.peekRecord('worker', '123abc');
|
||||
assert.ok(worker);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user