CI / test (push) Successful in 9m53s
Add host snapshot and network IPAM suggestions, image-driven form hydration, command palette, Host/Events/Settings views, offline banner, job drawer for deploy steps, and typed RPC errors. Mark roadmap complete.
37 lines
968 B
JavaScript
37 lines
968 B
JavaScript
import test from 'brittle'
|
|
import {
|
|
parseCidr,
|
|
cidrsOverlap,
|
|
nextFreePort,
|
|
} from '../server/utils/suggestions.js'
|
|
|
|
test('parseCidr and overlap detection', (t) => {
|
|
const a = parseCidr('172.17.0.0/16')
|
|
const b = parseCidr('172.17.5.0/24')
|
|
const c = parseCidr('172.18.0.0/16')
|
|
t.ok(a)
|
|
t.ok(cidrsOverlap(a, b))
|
|
t.not(cidrsOverlap(a, c))
|
|
t.is(parseCidr('bad'), null)
|
|
})
|
|
|
|
test('nextFreePort skips used', (t) => {
|
|
t.is(nextFreePort(8080, [8080, 8081]), 8082)
|
|
t.is(nextFreePort(80, []), 80)
|
|
})
|
|
|
|
test('MethodRoles cover suggestion methods', async (t) => {
|
|
const { Methods, MethodRoles, roleAllows, Roles } = await import('../shared/protocol.js')
|
|
for (const m of [
|
|
Methods.getHostSnapshot,
|
|
Methods.suggestNetworkIPAM,
|
|
Methods.suggestFromImage,
|
|
Methods.suggestDefaults,
|
|
Methods.listUsedHostPorts,
|
|
Methods.suggestResourceName,
|
|
]) {
|
|
t.ok(MethodRoles[m], m)
|
|
t.ok(roleAllows(Roles.viewer, m), `viewer can ${m}`)
|
|
}
|
|
})
|