Skip to content

Commit

Permalink
style: autoformatter
Browse files Browse the repository at this point in the history
  • Loading branch information
laduke committed Apr 18, 2024
1 parent 72f5837 commit 2b79fc8
Showing 1 changed file with 56 additions and 53 deletions.
109 changes: 56 additions & 53 deletions test/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFileSync } from "node:fs";
import { describe, it, before } from "node:test";
import assert from "node:assert";
import semver from 'semver'
import semver from "semver";

import { GenericContainer } from "testcontainers";
import createClient from "openapi-fetch";
Expand All @@ -15,7 +15,7 @@ import { AnyValidateFunction } from "ajv/dist/core.js";
const Ajv = _Ajv.default;
const addFormats = _addFormats.default;

const ZT_VERSION = process.env.ZT_VERSION || "1.12.2"
const ZT_VERSION = process.env.ZT_VERSION || "1.12.2";

function createCreateClient(token: string, port: number) {
const authToken = token;
Expand Down Expand Up @@ -57,7 +57,7 @@ function assertValid(

const ZEROTIER_API_SECRET = "asdf";

describe("API exercise", async function() {
describe("API exercise", async function () {
let network_id: string;
const node_id = "1122334455";
let container;
Expand All @@ -81,7 +81,7 @@ describe("API exercise", async function() {
client = createCreateClient(ZEROTIER_API_SECRET, apiPort);
});

describe("GET endpoints", async function() {
describe("GET endpoints", async function () {
const map: { path: PathsWithMethod<paths, "get">; id: string }[] = [
{ path: "/status", id: "NodeStatus" },
{ path: "/controller", id: "ControllerStatus" },
Expand Down Expand Up @@ -227,64 +227,67 @@ describe("API exercise", async function() {
});
});

describe("Unstable APIs", { skip: semver.lte(ZT_VERSION, "1.12.2") }, async () => {
it("Sets the member name", async () => {
const { data } = await client.POST(
"/controller/network/{network_id}/member/{node_id}",
{
params: { path: { network_id, node_id } },
body: { authorized: true, name: "bob" },
},
);
assert(data);

const validator = createValidator("ControllerNetworkMember");
assertValid(validator, data);
});

it("Lists full networks", async () => {
const { data } = await client.GET("/unstable/controller/network");
assert(data);
describe(
"Unstable APIs",
{ skip: semver.lte(ZT_VERSION, "1.12.2") },
async () => {
it("Sets the member name", async () => {
const { data } = await client.POST(
"/controller/network/{network_id}/member/{node_id}",
{
params: { path: { network_id, node_id } },
body: { authorized: true, name: "bob" },
},
);
assert(data);

const validator = createValidator("ControllerNetworkMember");
assertValid(validator, data);
});

const networksValidator = createValidator("ControllerNetworks");
it("Lists full networks", async () => {
const { data } = await client.GET("/unstable/controller/network");
assert(data);

assertValid(networksValidator, data);
});
const networksValidator = createValidator("ControllerNetworks");

it("Lists full network members", async () => {
const { data } = await client.GET(
"/unstable/controller/network/{network_id}/member",
{ params: { path: { network_id } } },
);
assert(data);
assertValid(networksValidator, data);
});

const networksValidator = createValidator(
"ControllerNetworkMemberListFull",
);
it("Lists full network members", async () => {
const { data } = await client.GET(
"/unstable/controller/network/{network_id}/member",
{ params: { path: { network_id } } },
);
assert(data);

assertValid(networksValidator, data);
});
const networksValidator = createValidator(
"ControllerNetworkMemberListFull",
);

it("Gets the member name", async () => {
const { data } = await client.GET(
"/controller/network/{network_id}/member/{node_id}",
{
params: { path: { network_id, node_id } },
},
);
assert(data);
assert.equal("bob", data.name);
assertValid(networksValidator, data);
});

const validator = createValidator("ControllerNetworkMember");
assertValid(validator, data);
});
});
it("Gets the member name", async () => {
const { data } = await client.GET(
"/controller/network/{network_id}/member/{node_id}",
{
params: { path: { network_id, node_id } },
},
);
assert(data);
assert.equal("bob", data.name);

const validator = createValidator("ControllerNetworkMember");
assertValid(validator, data);
});
},
);

it("Deletes the network by ID", async () => {
const { data } = await client.DELETE(
"/controller/network/{network_id}",
{ params: { path: { network_id } } },
);
const { data } = await client.DELETE("/controller/network/{network_id}", {
params: { path: { network_id } },
});
const networkDelValidator = createValidator("ControllerNetwork");
assertValid(networkDelValidator, data);
});
Expand Down

0 comments on commit 2b79fc8

Please sign in to comment.