chore: Add the feature for migration

This commit is contained in:
BluJ
2023-02-16 16:24:11 -07:00
parent df89119193
commit 6d1181eba3
12 changed files with 1150 additions and 531 deletions

View File

@@ -1,43 +1,45 @@
import { Config } from "./config.ts";
import { Pointer } from "./pointer.ts";
import { Value } from "./value.ts";
import { expect } from "https://deno.land/x/expect@v0.2.9/mod.ts";
const { test } = Deno;
test("Pointer", () => {
test("String", () => {
const bitcoinPropertiesBuilt: {
"peer-tor-address": {
name: string;
description: string;
type: "pointer";
subtype: "package";
"package-id": string;
target: "tor-address";
interface: string;
description: string | null;
type: "string";
};
} = Config.withValue(
"peer-tor-address",
Value.pointer(
Pointer.packageTorAddress({
name: "Peer Tor Address",
} = Config.of(
{
"peer-tor-address": Value.string({
name: "Peer tor address",
default: "",
description: "The Tor address of the peer interface",
"package-id": "bitcoind",
interface: "peer",
warning: null,
nullable: false,
masked: true,
placeholder: null,
pattern: null,
"pattern-description": null,
textarea: null,
}),
),
},
).build();
expect(JSON.stringify(bitcoinPropertiesBuilt)).toEqual(
/*json*/ `{
"peer-tor-address": {
"type": "pointer",
"subtype": "package",
"target": "tor-address",
"name": "Peer Tor Address",
"type": "string",
"name": "Peer tor address",
"default": "",
"description": "The Tor address of the peer interface",
"package-id": "bitcoind",
"interface": "peer",
"warning": null
"warning": null,
"nullable": false,
"masked": true,
"placeholder": null,
"pattern": null,
"pattern-description": null,
"textarea": null
}}`
.replaceAll("\n", " ")
.replaceAll(/\s{2,}/g, "")