-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclovapi-proxy.test.js
More file actions
39 lines (34 loc) · 1.52 KB
/
Copy pathclovapi-proxy.test.js
File metadata and controls
39 lines (34 loc) · 1.52 KB
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
const assert = require("node:assert/strict");
const test = require("node:test");
const {
buildProxyStartArgs,
buildProxyStopArgs,
buildProxyStatusArgs,
buildProxyHealthArgs,
} = require("./clovapi-proxy");
test("buildProxyStartArgs keeps explicit host", () => {
const { args, host, port } = buildProxyStartArgs({ host: "127.0.0.1", port: 1234 });
assert.deepEqual(args, ["proxy", "start", "--host", "127.0.0.1", "--port", "1234"]);
assert.equal(host, "127.0.0.1");
assert.equal(port, 1234);
});
test("buildProxyStartArgs uses wildcard host by default", () => {
const { args, host, port } = buildProxyStartArgs({});
assert.deepEqual(args, ["proxy", "start", "--host", "0.0.0.0", "--port", "27483"]);
assert.equal(host, "0.0.0.0");
assert.equal(port, 27483);
});
test("buildProxyStopArgs keeps explicit host", () => {
const { args, host, port } = buildProxyStopArgs({ host: "127.0.0.1", port: 1234 });
assert.deepEqual(args, ["proxy", "stop", "--host", "127.0.0.1", "--port", "1234"]);
assert.equal(host, "127.0.0.1");
assert.equal(port, 1234);
});
test("buildProxyStatusArgs includes json flag", () => {
const { args } = buildProxyStatusArgs({ host: "127.0.0.1", port: 27483 });
assert.deepEqual(args, ["proxy", "status", "--json", "--host", "127.0.0.1", "--port", "27483"]);
});
test("buildProxyHealthArgs includes json flag", () => {
const { args } = buildProxyHealthArgs({ host: "127.0.0.1", port: 27483 });
assert.deepEqual(args, ["proxy", "health", "--json", "--host", "127.0.0.1", "--port", "27483"]);
});