open-nomad/ui/mirage/factories/service.js
Buck Doyle 5da134d074
UI: Change Mirage data to be stable in development (#6389)
This sets a default-but-query-configurable Faker seed in development,
via faker-seed. It also changes uses of Math.random to use Faker’s
randomness so auto-generated data remains stable in development.
2019-10-03 09:13:08 -05:00

31 lines
767 B
JavaScript

import { Factory } from 'ember-cli-mirage';
import faker from 'nomad-ui/mirage/faker';
import { provide } from '../utils';
export default Factory.extend({
name: id => `${faker.hacker.noun().dasherize()}-${id}-service`,
portLabel: () => faker.hacker.noun().dasherize(),
tags: () => {
if (!faker.random.boolean()) {
return provide(
faker.random.number({ min: 0, max: 2 }),
faker.hacker.noun.bind(faker.hacker.noun)
);
} else {
return null;
}
},
Connect: {
SidecarService: {
Proxy: {
Upstreams: [
{
DestinationName: faker.hacker.noun().dasherize(),
LocalBindPort: faker.random.number({ min: 5000, max: 60000 }),
},
],
},
},
},
});