Bundled state added

This commit is contained in:
Piotr Pekala 2019-03-26 06:38:10 -07:00
parent 9ff7a58df0
commit ca9cb13c2b
3 changed files with 5 additions and 8 deletions

View File

@ -1,5 +1,5 @@
export type ServerAuthorization = 'basic' | 'none';
export type ServerLocation = 'local' | 'remote';
export type ServerLocation = 'local' | 'remote' | 'bundled';
export type ServerStatus = 'stopped' | 'starting' | 'running';
export class Server {
@ -13,6 +13,5 @@ export class Server {
authorization: ServerAuthorization;
login: string;
password: string;
is_local: boolean;
status: ServerStatus;
}

View File

@ -151,8 +151,7 @@ describe('ServerService', () => {
expectedServer.name = 'local';
expectedServer.host = 'hostname';
expectedServer.port = 9999;
expectedServer.location = 'remote';
expectedServer.is_local = true;
expectedServer.location = 'bundled';
service.getLocalServer('hostname', 9999).then(() => {
expect(service.create).toHaveBeenCalledWith(expectedServer);
@ -165,7 +164,7 @@ describe('ServerService', () => {
server.name = 'local';
server.host = 'hostname';
server.port = 9999;
server.is_local = true;
server.location = 'bundled';
spyOn(db, 'getAll').and.returnValue(Promise.resolve([server]));
spyOn(service, 'update').and.returnValue(Promise.resolve(new Server()));

View File

@ -58,7 +58,7 @@ export class ServerService {
public getLocalServer(host: string, port: number) {
const promise = new Promise((resolve, reject) => {
this.findAll().then((servers: Server[]) => {
const local = servers.find(server => server.is_local);
const local = servers.find(server => server.location === 'bundled');
if (local) {
local.host = host;
local.port = port;
@ -70,8 +70,7 @@ export class ServerService {
server.name = 'local';
server.host = host;
server.port = port;
server.location = 'remote';
server.is_local = true;
server.location = 'bundled';
this.create(server).then(created => {
resolve(created);
}, reject);