chore: 🤖 add host set mocks
This commit is contained in:
7 files changed
+60
-3
No files matched your search
@@ -1,4 +1,20 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogRoute extends Route {
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Load a host catalog.
|
||||
* @param {object} params
|
||||
* @param {string} params.host_catalog_id
|
||||
* @return {HostCatalogModel}
|
||||
*/
|
||||
async model({ host_catalog_id }) {
|
||||
const { id: scopeID } = this.modelFor('scopes.scope');
|
||||
return this.store.findRecord('host-catalog', host_catalog_id, {
|
||||
adapterOptions: { scopeID },
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -88,6 +88,14 @@ export default function() {
|
||||
this.patch('/scopes/:scope_id/host-catalogs/:id');
|
||||
this.del('/scopes/:scope_id/host-catalogs/:id');
|
||||
|
||||
// host-set
|
||||
|
||||
this.get('/scopes/:scope_id/host-catalogs/:host_catalog_id/host-sets');
|
||||
this.post('/scopes/:scope_id/host-catalogs/:host_catalog_id/host-sets');
|
||||
this.get('/scopes/:scope_id/host-catalogs/:host_catalog_id/host-sets/:id');
|
||||
this.patch('/scopes/:scope_id/host-catalogs/:host_catalog_id/host-sets/:id');
|
||||
this.del('/scopes/:scope_id/host-catalogs/:host_catalog_id/host-sets/:id');
|
||||
|
||||
// Uncomment the following line and the Response import above
|
||||
// Then change the response code to simulate error responses.
|
||||
// this.get('/scopes/:scope_id/projects', () => new Response(505));
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
import factory from '../generated/factories/host-catalog';
|
||||
import { trait } from 'ember-cli-mirage';
|
||||
|
||||
export default factory.extend();
|
||||
export default factory.extend({
|
||||
|
||||
/**
|
||||
* Create catalogs with associated host sets and hosts.
|
||||
*/
|
||||
withChildren: trait({
|
||||
afterCreate(record, server) {
|
||||
const host_set_ids = server.createList('host-set', 3).map(set => set.id);
|
||||
record.update({ host_set_ids });
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
import factory from '../generated/factories/host-set';
|
||||
|
||||
export default factory.extend();
|
||||
@@ -14,7 +14,7 @@ export default factory.extend({
|
||||
}, 'withChildren');
|
||||
}
|
||||
if (record.type === 'org') {
|
||||
server.createList('scope', 5, {
|
||||
server.createList('scope', 3, {
|
||||
type: 'project',
|
||||
scope: { id: record.id, type: record.type }
|
||||
});
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Factory } from 'ember-cli-mirage';
|
||||
import { random, date } from 'faker';
|
||||
|
||||
/**
|
||||
* GeneratedHostSetModelFactory
|
||||
*/
|
||||
export default Factory.extend({
|
||||
|
||||
type: 'static',
|
||||
name: () => random.words(),
|
||||
description: () => random.words(),
|
||||
created_time: () => date.recent(),
|
||||
updated_time: () => date.recent(),
|
||||
version: () => random.number(),
|
||||
size: () => random.number(),
|
||||
|
||||
});
|
||||
@@ -27,7 +27,7 @@ export default function(server) {
|
||||
|
||||
server.db.scopes.where({type: 'project'}).forEach(projectScope => {
|
||||
const scope = { id: projectScope.id, type: projectScope.type };
|
||||
server.createList('host-catalog', 2, { scope });
|
||||
server.createList('host-catalog', 2, { scope }, 'withChildren');
|
||||
});
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user