-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconf_test.js
67 lines (48 loc) · 2.33 KB
/
conf_test.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import prod from "./conf/config_prod.js";
import nonprod from "./conf/config_nonprod.js";
const assertValidUrl = (url, message) => {
try {
assert.ok(new URL(url), message);
} catch (e) {
assert.ok(false, message);
}
}
describe('config', () => {
const envs = [{ name: "prod", config: prod }, { name: "nonprod", config: nonprod }]
for (const env of envs) {
describe(`for environment ${env.name}`, () => {
const config = env.config;
it(`regions should be valid`, () => {
assert.ok(config.regions, "Regions must be defined");
assert.ok(!!config.regions.find((r) => r.id === "global"), "Global must be defined");
assert.ok(config.regions.length > 1, "At least another region");
});
it(`endpoints should be valid`, () => {
assert.ok(config.endpoints, "Endpoints must be defined");
assert.ok(config.endpoints.length > 0, "At least one endpoint");
});
for (const endpoint of config.endpoints) {
it(`endpoint ${endpoint.id} should be valid`, () => {
assert.ok(endpoint.id, "An id is defined");
assert.ok(endpoint.label, "A label is defined");
assert.ok(endpoint.services, "Services are defined");
assertValidUrl(endpoint.website_url, "A website_url is defined and valid");
});
describe(`for endpoint ${endpoint.id}`, () => {
for (const service of endpoint.services) {
it(`service ${service.type} should be valid`, () => {
assert.ok(service.type, "Service type is defined");
assert.ok(["feed", "enclosure", "prefix"].includes(service.type), "Service type is supported");
assertValidUrl(service.url, "Service url is defined and valid");
if ("prefix" === service.type) {
assertValidUrl(service.expected_url, "Expected url is defined and valid");
}
});
}
});
}
});
}
});