-
Notifications
You must be signed in to change notification settings - Fork 905
/
databaseEmulator.ts
41 lines (33 loc) · 1.02 KB
/
databaseEmulator.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as javaEmulators from "../serve/javaEmulators";
import { EmulatorInfo, EmulatorInstance, Emulators } from "../emulator/types";
import { Constants } from "./constants";
interface DatabaseEmulatorArgs {
port?: number;
host?: string;
functions_emulator_port?: number;
functions_emulator_host?: string;
}
export class DatabaseEmulator implements EmulatorInstance {
constructor(private args: DatabaseEmulatorArgs) {}
async start(): Promise<void> {
return javaEmulators.start(Emulators.DATABASE, this.args);
}
async connect(): Promise<void> {
// The Database emulator has no "connect" phase.
return Promise.resolve();
}
async stop(): Promise<void> {
return javaEmulators.stop(Emulators.DATABASE);
}
getInfo(): EmulatorInfo {
const host = this.args.host || Constants.getDefaultHost(Emulators.DATABASE);
const port = this.args.port || Constants.getDefaultPort(Emulators.DATABASE);
return {
host,
port,
};
}
getName(): Emulators {
return Emulators.DATABASE;
}
}