mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
Refactor/actions (#2733)
* store, properties, manifest * interfaces * init and backups * fix init and backups * file models * more versions * dependencies * config except dynamic types * clean up config * remove disabled from non-dynamic vaues * actions * standardize example code block formats * wip: actions refactor Co-authored-by: Jade <Blu-J@users.noreply.github.com> * commit types * fix types * update types * update action request type * update apis * add description to actionrequest * clean up imports * revert package json * chore: Remove the recursive to the index * chore: Remove the other thing I was testing * flatten action requests * update container runtime with new config paradigm * new actions strategy * seems to be working * misc backend fixes * fix fe bugs * only show breakages if breakages * only show success modal if result * don't panic on failed removal * hide config from actions page * polyfill autoconfig * use metadata strategy for actions instead of prev * misc fixes * chore: split the sdk into 2 libs (#2736) * follow sideload progress (#2718) * follow sideload progress * small bugfix * shareReplay with no refcount false * don't wrap sideload progress in RPCResult * dont present toast --------- Co-authored-by: Aiden McClelland <me@drbonez.dev> * chore: Add the initial of the creation of the two sdk * chore: Add in the baseDist * chore: Add in the baseDist * chore: Get the web and the runtime-container running * chore: Remove the empty file * chore: Fix it so the container-runtime works --------- Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com> Co-authored-by: Aiden McClelland <me@drbonez.dev> * misc fixes * update todos * minor clean up * fix link script * update node version in CI test * fix node version syntax in ci build * wip: fixing callbacks * fix sdk makefile dependencies * add support for const outside of main * update apis * don't panic! * Chore: Capture weird case on rpc, and log that * fix procedure id issue * pass input value for dep auto config * handle disabled and warning for actions * chore: Fix for link not having node_modules * sdk fixes * fix build * fix build * fix build --------- Co-authored-by: Matt Hill <mattnine@protonmail.com> Co-authored-by: Jade <Blu-J@users.noreply.github.com> Co-authored-by: J H <dragondef@gmail.com> Co-authored-by: Jade <2364004+Blu-J@users.noreply.github.com> Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com>
This commit is contained in:
355
sdk/base/lib/test/exverList.test.ts
Normal file
355
sdk/base/lib/test/exverList.test.ts
Normal file
@@ -0,0 +1,355 @@
|
||||
import { VersionRange, ExtendedVersion } from "../exver"
|
||||
describe("ExVer", () => {
|
||||
{
|
||||
{
|
||||
const checker = VersionRange.parse("*")
|
||||
test("VersionRange.parse('*')", () => {
|
||||
checker.satisfiedBy(ExtendedVersion.parse("1:0"))
|
||||
checker.satisfiedBy(ExtendedVersion.parse("1.2:0"))
|
||||
checker.satisfiedBy(ExtendedVersion.parse("1.2.3:0"))
|
||||
checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4"))
|
||||
checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4.5"))
|
||||
checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4.5.6"))
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(true)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4"))).toEqual(
|
||||
true,
|
||||
)
|
||||
})
|
||||
test("VersionRange.parse('*') invalid", () => {
|
||||
expect(() => checker.satisfiedBy(ExtendedVersion.parse("a"))).toThrow()
|
||||
expect(() => checker.satisfiedBy(ExtendedVersion.parse(""))).toThrow()
|
||||
expect(() =>
|
||||
checker.satisfiedBy(ExtendedVersion.parse("1..3")),
|
||||
).toThrow()
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
const checker = VersionRange.parse(">1.2.3:4")
|
||||
test(`VersionRange.parse(">1.2.3:4") valid`, () => {
|
||||
expect(
|
||||
checker.satisfiedBy(ExtendedVersion.parse("2-beta.123:0")),
|
||||
).toEqual(true)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(true)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:5"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4.1"))).toEqual(
|
||||
true,
|
||||
)
|
||||
})
|
||||
|
||||
test(`VersionRange.parse(">1.2.3:4") invalid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(false)
|
||||
})
|
||||
}
|
||||
{
|
||||
const checker = VersionRange.parse("=1.2.3")
|
||||
test(`VersionRange.parse("=1.2.3") valid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
})
|
||||
|
||||
test(`VersionRange.parse("=1.2.3") invalid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(false)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:1"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
const checker = VersionRange.parse(">=1.2.3:4")
|
||||
test(`VersionRange.parse(">=1.2.3:4") valid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(true)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:5"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4.1"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4"))).toEqual(
|
||||
true,
|
||||
)
|
||||
})
|
||||
|
||||
test(`VersionRange.parse(">=1.2.3:4") invalid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(false)
|
||||
})
|
||||
}
|
||||
{
|
||||
const checker = VersionRange.parse("<1.2.3:4")
|
||||
test(`VersionRange.parse("<1.2.3:4") invalid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(false)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:5"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4.1"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4"))).toEqual(
|
||||
false,
|
||||
)
|
||||
})
|
||||
|
||||
test(`VersionRange.parse("<1.2.3:4") valid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(true)
|
||||
})
|
||||
}
|
||||
{
|
||||
const checker = VersionRange.parse("<=1.2.3:4")
|
||||
test(`VersionRange.parse("<=1.2.3:4") invalid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(false)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:5"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4.1"))).toEqual(
|
||||
false,
|
||||
)
|
||||
})
|
||||
|
||||
test(`VersionRange.parse("<=1.2.3:4") valid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(true)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4"))).toEqual(
|
||||
true,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
const checkA = VersionRange.parse(">1")
|
||||
const checkB = VersionRange.parse("<=2")
|
||||
|
||||
const checker = checkA.and(checkB)
|
||||
test(`simple and(checkers) valid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(true)
|
||||
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.1:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
})
|
||||
test(`simple and(checkers) invalid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2.1:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(false)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(false)
|
||||
})
|
||||
}
|
||||
{
|
||||
const checkA = VersionRange.parse("<1")
|
||||
const checkB = VersionRange.parse("=2")
|
||||
|
||||
const checker = checkA.or(checkB)
|
||||
test(`simple or(checkers) valid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(true)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("0.1:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
})
|
||||
test(`simple or(checkers) invalid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2.1:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(false)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.1:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
const checker = VersionRange.parse("~1.2")
|
||||
test(`VersionRange.parse(~1.2) valid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.1:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
})
|
||||
test(`VersionRange.parse(~1.2) invalid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.3:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.3.1:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.1.1:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.1:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(false)
|
||||
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(false)
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
const checker = VersionRange.parse("~1.2").not()
|
||||
test(`VersionRange.parse(~1.2).not() valid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.3:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.3.1:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.1.1:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.1:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(true)
|
||||
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(true)
|
||||
})
|
||||
test(`VersionRange.parse(~1.2).not() invalid `, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.1:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
const checker = VersionRange.parse("!~1.2")
|
||||
test(`!(VersionRange.parse(~1.2)) valid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.3:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.3.1:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.1.1:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.1:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(true)
|
||||
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(true)
|
||||
})
|
||||
test(`!(VersionRange.parse(~1.2)) invalid `, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.1:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
const checker = VersionRange.parse("!>1.2.3:4")
|
||||
test(`VersionRange.parse("!>1.2.3:4") invalid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(false)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:5"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4.1"))).toEqual(
|
||||
false,
|
||||
)
|
||||
})
|
||||
|
||||
test(`VersionRange.parse("!>1.2.3:4") valid`, () => {
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:4"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.3:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(true)
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
test(">1 && =1.2", () => {
|
||||
const checker = VersionRange.parse(">1 && =1.2")
|
||||
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2.1:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
})
|
||||
test("=1 || =2", () => {
|
||||
const checker = VersionRange.parse("=1 || =2")
|
||||
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(true)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(true)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("3:0"))).toEqual(false)
|
||||
})
|
||||
|
||||
test(">1 && =1.2 || =2", () => {
|
||||
const checker = VersionRange.parse(">1 && =1.2 || =2")
|
||||
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.2:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(false)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(true)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("3:0"))).toEqual(false)
|
||||
})
|
||||
|
||||
test("&& before || order of operationns: <1.5 && >1 || >1.5 && <3", () => {
|
||||
const checker = VersionRange.parse("<1.5 && >1 || >1.5 && <3")
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.1:0"))).toEqual(
|
||||
true,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("2:0"))).toEqual(true)
|
||||
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1.5:0"))).toEqual(
|
||||
false,
|
||||
)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("1:0"))).toEqual(false)
|
||||
expect(checker.satisfiedBy(ExtendedVersion.parse("3:0"))).toEqual(false)
|
||||
})
|
||||
|
||||
test("Compare function on the emver", () => {
|
||||
const a = ExtendedVersion.parse("1.2.3:0")
|
||||
const b = ExtendedVersion.parse("1.2.4:0")
|
||||
|
||||
expect(a.compare(b)).toEqual("less")
|
||||
expect(b.compare(a)).toEqual("greater")
|
||||
expect(a.compare(a)).toEqual("equal")
|
||||
})
|
||||
test("Compare for sort function on the emver", () => {
|
||||
const a = ExtendedVersion.parse("1.2.3:0")
|
||||
const b = ExtendedVersion.parse("1.2.4:0")
|
||||
|
||||
expect(a.compareForSort(b)).toEqual(-1)
|
||||
expect(b.compareForSort(a)).toEqual(1)
|
||||
expect(a.compareForSort(a)).toEqual(0)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
148
sdk/base/lib/test/graph.test.ts
Normal file
148
sdk/base/lib/test/graph.test.ts
Normal file
@@ -0,0 +1,148 @@
|
||||
import { Graph } from "../util"
|
||||
|
||||
describe("graph", () => {
|
||||
{
|
||||
{
|
||||
test("findVertex", () => {
|
||||
const graph = new Graph<string, string>()
|
||||
const foo = graph.addVertex("foo", [], [])
|
||||
const bar = graph.addVertex(
|
||||
"bar",
|
||||
[{ from: foo, metadata: "foo-bar" }],
|
||||
[],
|
||||
)
|
||||
const baz = graph.addVertex(
|
||||
"baz",
|
||||
[{ from: bar, metadata: "bar-baz" }],
|
||||
[],
|
||||
)
|
||||
const qux = graph.addVertex(
|
||||
"qux",
|
||||
[{ from: baz, metadata: "baz-qux" }],
|
||||
[],
|
||||
)
|
||||
const match = Array.from(graph.findVertex((v) => v.metadata === "qux"))
|
||||
expect(match).toHaveLength(1)
|
||||
expect(match[0]).toBe(qux)
|
||||
})
|
||||
test("shortestPathA", () => {
|
||||
const graph = new Graph<string, string>()
|
||||
const foo = graph.addVertex("foo", [], [])
|
||||
const bar = graph.addVertex(
|
||||
"bar",
|
||||
[{ from: foo, metadata: "foo-bar" }],
|
||||
[],
|
||||
)
|
||||
const baz = graph.addVertex(
|
||||
"baz",
|
||||
[{ from: bar, metadata: "bar-baz" }],
|
||||
[],
|
||||
)
|
||||
const qux = graph.addVertex(
|
||||
"qux",
|
||||
[{ from: baz, metadata: "baz-qux" }],
|
||||
[],
|
||||
)
|
||||
graph.addEdge("foo-qux", foo, qux)
|
||||
expect(graph.shortestPath(foo, qux) || []).toHaveLength(1)
|
||||
})
|
||||
test("shortestPathB", () => {
|
||||
const graph = new Graph<string, string>()
|
||||
const foo = graph.addVertex("foo", [], [])
|
||||
const bar = graph.addVertex(
|
||||
"bar",
|
||||
[{ from: foo, metadata: "foo-bar" }],
|
||||
[],
|
||||
)
|
||||
const baz = graph.addVertex(
|
||||
"baz",
|
||||
[{ from: bar, metadata: "bar-baz" }],
|
||||
[],
|
||||
)
|
||||
const qux = graph.addVertex(
|
||||
"qux",
|
||||
[{ from: baz, metadata: "baz-qux" }],
|
||||
[],
|
||||
)
|
||||
graph.addEdge("bar-qux", bar, qux)
|
||||
expect(graph.shortestPath(foo, qux) || []).toHaveLength(2)
|
||||
})
|
||||
test("shortestPathC", () => {
|
||||
const graph = new Graph<string, string>()
|
||||
const foo = graph.addVertex("foo", [], [])
|
||||
const bar = graph.addVertex(
|
||||
"bar",
|
||||
[{ from: foo, metadata: "foo-bar" }],
|
||||
[],
|
||||
)
|
||||
const baz = graph.addVertex(
|
||||
"baz",
|
||||
[{ from: bar, metadata: "bar-baz" }],
|
||||
[],
|
||||
)
|
||||
const qux = graph.addVertex(
|
||||
"qux",
|
||||
[{ from: baz, metadata: "baz-qux" }],
|
||||
[{ to: foo, metadata: "qux-foo" }],
|
||||
)
|
||||
expect(graph.shortestPath(foo, qux) || []).toHaveLength(3)
|
||||
})
|
||||
test("bfs", () => {
|
||||
const graph = new Graph<string, string>()
|
||||
const foo = graph.addVertex("foo", [], [])
|
||||
const bar = graph.addVertex(
|
||||
"bar",
|
||||
[{ from: foo, metadata: "foo-bar" }],
|
||||
[],
|
||||
)
|
||||
const baz = graph.addVertex(
|
||||
"baz",
|
||||
[{ from: bar, metadata: "bar-baz" }],
|
||||
[],
|
||||
)
|
||||
const qux = graph.addVertex(
|
||||
"qux",
|
||||
[
|
||||
{ from: foo, metadata: "foo-qux" },
|
||||
{ from: baz, metadata: "baz-qux" },
|
||||
],
|
||||
[],
|
||||
)
|
||||
const bfs = Array.from(graph.breadthFirstSearch(foo))
|
||||
expect(bfs).toHaveLength(4)
|
||||
expect(bfs[0]).toBe(foo)
|
||||
expect(bfs[1]).toBe(bar)
|
||||
expect(bfs[2]).toBe(qux)
|
||||
expect(bfs[3]).toBe(baz)
|
||||
})
|
||||
test("reverseBfs", () => {
|
||||
const graph = new Graph<string, string>()
|
||||
const foo = graph.addVertex("foo", [], [])
|
||||
const bar = graph.addVertex(
|
||||
"bar",
|
||||
[{ from: foo, metadata: "foo-bar" }],
|
||||
[],
|
||||
)
|
||||
const baz = graph.addVertex(
|
||||
"baz",
|
||||
[{ from: bar, metadata: "bar-baz" }],
|
||||
[],
|
||||
)
|
||||
const qux = graph.addVertex(
|
||||
"qux",
|
||||
[
|
||||
{ from: foo, metadata: "foo-qux" },
|
||||
{ from: baz, metadata: "baz-qux" },
|
||||
],
|
||||
[],
|
||||
)
|
||||
const bfs = Array.from(graph.reverseBreadthFirstSearch(qux))
|
||||
expect(bfs).toHaveLength(4)
|
||||
expect(bfs[0]).toBe(qux)
|
||||
expect(bfs[1]).toBe(foo)
|
||||
expect(bfs[2]).toBe(baz)
|
||||
expect(bfs[3]).toBe(bar)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
29
sdk/base/lib/test/inputSpecTypes.test.ts
Normal file
29
sdk/base/lib/test/inputSpecTypes.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import {
|
||||
ListValueSpecOf,
|
||||
isValueSpecListOf,
|
||||
} from "../actions/input/inputSpecTypes"
|
||||
import { InputSpec } from "../actions/input/builder/inputSpec"
|
||||
import { List } from "../actions/input/builder/list"
|
||||
import { Value } from "../actions/input/builder/value"
|
||||
|
||||
describe("InputSpec Types", () => {
|
||||
test("isValueSpecListOf", async () => {
|
||||
const options = [List.obj, List.text]
|
||||
for (const option of options) {
|
||||
const test = (option as any)(
|
||||
{} as any,
|
||||
{ spec: InputSpec.of({}) } as any,
|
||||
) as any
|
||||
const someList = await Value.list(test).build({} as any)
|
||||
if (isValueSpecListOf(someList, "text")) {
|
||||
someList.spec satisfies ListValueSpecOf<"text">
|
||||
} else if (isValueSpecListOf(someList, "object")) {
|
||||
someList.spec satisfies ListValueSpecOf<"object">
|
||||
} else {
|
||||
throw new Error(
|
||||
"Failed to figure out the type: " + JSON.stringify(someList),
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
95
sdk/base/lib/test/startosTypeValidation.test.ts
Normal file
95
sdk/base/lib/test/startosTypeValidation.test.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { Effects } from "../types"
|
||||
import {
|
||||
CheckDependenciesParam,
|
||||
ClearActionRequestsParams,
|
||||
ClearActionsParams,
|
||||
ClearBindingsParams,
|
||||
ClearCallbacksParams,
|
||||
ClearServiceInterfacesParams,
|
||||
GetActionInputParams,
|
||||
GetStoreParams,
|
||||
RequestActionParams,
|
||||
RunActionParams,
|
||||
SetDataVersionParams,
|
||||
SetMainStatus,
|
||||
SetStoreParams,
|
||||
} from ".././osBindings"
|
||||
import { CreateSubcontainerFsParams } from ".././osBindings"
|
||||
import { DestroySubcontainerFsParams } from ".././osBindings"
|
||||
import { BindParams } from ".././osBindings"
|
||||
import { GetHostInfoParams } from ".././osBindings"
|
||||
import { SetHealth } from ".././osBindings"
|
||||
import { ExposeForDependentsParams } from ".././osBindings"
|
||||
import { GetSslCertificateParams } from ".././osBindings"
|
||||
import { GetSslKeyParams } from ".././osBindings"
|
||||
import { GetServiceInterfaceParams } from ".././osBindings"
|
||||
import { SetDependenciesParams } from ".././osBindings"
|
||||
import { GetSystemSmtpParams } from ".././osBindings"
|
||||
import { GetServicePortForwardParams } from ".././osBindings"
|
||||
import { ExportServiceInterfaceParams } from ".././osBindings"
|
||||
import { GetPrimaryUrlParams } from ".././osBindings"
|
||||
import { ListServiceInterfacesParams } from ".././osBindings"
|
||||
import { ExportActionParams } from ".././osBindings"
|
||||
import { MountParams } from ".././osBindings"
|
||||
import { StringObject } from "../util"
|
||||
function typeEquality<ExpectedType>(_a: ExpectedType) {}
|
||||
|
||||
type WithCallback<T> = Omit<T, "callback"> & { callback: () => void }
|
||||
|
||||
type EffectsTypeChecker<T extends StringObject = Effects> = {
|
||||
[K in keyof T]: T[K] extends (args: infer A) => any
|
||||
? A
|
||||
: T[K] extends StringObject
|
||||
? EffectsTypeChecker<T[K]>
|
||||
: never
|
||||
}
|
||||
|
||||
describe("startosTypeValidation ", () => {
|
||||
test(`checking the params match`, () => {
|
||||
typeEquality<EffectsTypeChecker>({
|
||||
constRetry: {},
|
||||
clearCallbacks: {} as ClearCallbacksParams,
|
||||
action: {
|
||||
clear: {} as ClearActionsParams,
|
||||
export: {} as ExportActionParams,
|
||||
getInput: {} as GetActionInputParams,
|
||||
run: {} as RunActionParams,
|
||||
request: {} as RequestActionParams,
|
||||
clearRequests: {} as ClearActionRequestsParams,
|
||||
},
|
||||
subcontainer: {
|
||||
createFs: {} as CreateSubcontainerFsParams,
|
||||
destroyFs: {} as DestroySubcontainerFsParams,
|
||||
},
|
||||
clearBindings: {} as ClearBindingsParams,
|
||||
getInstalledPackages: undefined,
|
||||
bind: {} as BindParams,
|
||||
getHostInfo: {} as WithCallback<GetHostInfoParams>,
|
||||
restart: undefined,
|
||||
shutdown: undefined,
|
||||
setDataVersion: {} as SetDataVersionParams,
|
||||
getDataVersion: undefined,
|
||||
setHealth: {} as SetHealth,
|
||||
exposeForDependents: {} as ExposeForDependentsParams,
|
||||
getSslCertificate: {} as WithCallback<GetSslCertificateParams>,
|
||||
getSslKey: {} as GetSslKeyParams,
|
||||
getServiceInterface: {} as WithCallback<GetServiceInterfaceParams>,
|
||||
setDependencies: {} as SetDependenciesParams,
|
||||
store: {
|
||||
get: {} as any, // as GetStoreParams,
|
||||
set: {} as any, // as SetStoreParams,
|
||||
},
|
||||
getSystemSmtp: {} as WithCallback<GetSystemSmtpParams>,
|
||||
getContainerIp: undefined,
|
||||
getServicePortForward: {} as GetServicePortForwardParams,
|
||||
clearServiceInterfaces: {} as ClearServiceInterfacesParams,
|
||||
exportServiceInterface: {} as ExportServiceInterfaceParams,
|
||||
getPrimaryUrl: {} as WithCallback<GetPrimaryUrlParams>,
|
||||
listServiceInterfaces: {} as WithCallback<ListServiceInterfacesParams>,
|
||||
mount: {} as MountParams,
|
||||
checkDependencies: {} as CheckDependenciesParam,
|
||||
getDependencies: undefined,
|
||||
setMainStatus: {} as SetMainStatus,
|
||||
})
|
||||
})
|
||||
})
|
||||
30
sdk/base/lib/test/util.deepMerge.test.ts
Normal file
30
sdk/base/lib/test/util.deepMerge.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { deepEqual } from "../util"
|
||||
import { deepMerge } from "../util"
|
||||
|
||||
describe("deepMerge", () => {
|
||||
test("deepMerge({}, {a: 1}, {b: 2}) should return {a: 1, b: 2}", () => {
|
||||
expect(deepMerge({}, { a: 1 }, { b: 2 })).toEqual({ a: 1, b: 2 })
|
||||
})
|
||||
test("deepMerge(null, [1,2,3]) should equal [1,2,3]", () => {
|
||||
expect(deepMerge(null, [1, 2, 3])).toEqual([1, 2, 3])
|
||||
})
|
||||
test("deepMerge({a: {b: 1, c:2}}, {a: {b: 3}}) should equal {a: {b: 3, c: 2}}", () => {
|
||||
expect(deepMerge({ a: { b: 1, c: 2 } }, { a: { b: 3 } })).toEqual({
|
||||
a: { b: 3, c: 2 },
|
||||
})
|
||||
})
|
||||
test("deepMerge({a: {b: 1, c:2}}, {a: {b: 3}}) should equal {a: {b: 3, c: 2}} with deep equal", () => {
|
||||
expect(
|
||||
deepEqual(deepMerge({ a: { b: 1, c: 2 } }, { a: { b: 3 } }), {
|
||||
a: { b: 3, c: 2 },
|
||||
}),
|
||||
).toBeTruthy()
|
||||
})
|
||||
test("Test that merging lists has Set semantics", () => {
|
||||
const merge = deepMerge(["a", "b"], ["b", "c"])
|
||||
expect(merge).toHaveLength(3)
|
||||
expect(merge).toContain("a")
|
||||
expect(merge).toContain("b")
|
||||
expect(merge).toContain("c")
|
||||
})
|
||||
})
|
||||
20
sdk/base/lib/test/util.getNetworkInterface.test.ts
Normal file
20
sdk/base/lib/test/util.getNetworkInterface.test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { getHostname } from "../util/getServiceInterface"
|
||||
|
||||
describe("getHostname ", () => {
|
||||
const inputToExpected = [
|
||||
["http://localhost:3000", "localhost"],
|
||||
["http://localhost", "localhost"],
|
||||
["localhost", "localhost"],
|
||||
["http://127.0.0.1/", "127.0.0.1"],
|
||||
["http://127.0.0.1/testing/1234?314345", "127.0.0.1"],
|
||||
["127.0.0.1/", "127.0.0.1"],
|
||||
["http://mail.google.com/", "mail.google.com"],
|
||||
["mail.google.com/", "mail.google.com"],
|
||||
]
|
||||
|
||||
for (const [input, expectValue] of inputToExpected) {
|
||||
test(`should return ${expectValue} for ${input}`, () => {
|
||||
expect(getHostname(input)).toEqual(expectValue)
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user