Skip to content

Commit

Permalink
test(incus): cleanup resources
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Dec 30, 2024
1 parent 20e21a3 commit 76f549c
Show file tree
Hide file tree
Showing 5 changed files with 398 additions and 302 deletions.
52 changes: 31 additions & 21 deletions packages/incus/test/config/device/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,39 @@ describe("incus.config.device.delete", function () {
{
$ssh: ssh,
},
async function () {
await this.incus.delete({
name: "nikita-config-device-delete-2",
force: true,
});
await this.incus.init({
image: `images:${test.images.alpine}`,
name: "nikita-config-device-delete-2",
async function ({ registry }) {
registry.register("clean", async function () {
await this.incus.delete({
name: "nikita-config-device-delete-2",
force: true,
});
});
await this.incus.config.device({
name: "nikita-config-device-delete-2",
device: "test",
type: "unix-char",
properties: {
source: "/dev/urandom",
path: "/testrandom",
},
});
const { $status } = await this.incus.config.device.delete({
device: "test",
name: "nikita-config-device-delete-2",
registry.register("test", async function () {
await this.incus.init({
image: `images:${test.images.alpine}`,
name: "nikita-config-device-delete-2",
});
await this.incus.config.device({
name: "nikita-config-device-delete-2",
device: "test",
type: "unix-char",
properties: {
source: "/dev/urandom",
path: "/testrandom",
},
});
const { $status } = await this.incus.config.device.delete({
device: "test",
name: "nikita-config-device-delete-2",
});
$status.should.be.true();
});
$status.should.be.true();
try {
await this.clean();
await this.test();
} finally {
await this.clean();
}
},
);
};
Expand Down
86 changes: 53 additions & 33 deletions packages/incus/test/config/device/exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,30 @@ describe("incus.config.device.exists", function () {
{
$ssh: ssh,
},
async function () {
await this.incus.delete({
name: "nikita-config-device-exists-1",
force: true,
async function ({ registry }) {
registry.register("clean", async function () {
await this.incus.delete({
name: "nikita-config-device-exists-1",
force: true,
});
});
await this.incus.init({
image: `images:${test.images.alpine}`,
name: "nikita-config-device-exists-1",
registry.register("test", async function () {
await this.incus.init({
image: `images:${test.images.alpine}`,
name: "nikita-config-device-exists-1",
});
const { exists } = await this.incus.config.device.exists({
name: "nikita-config-device-exists-1",
device: "test",
});
exists.should.be.false();
});
const { exists } = await this.incus.config.device.exists({
name: "nikita-config-device-exists-1",
device: "test",
});
exists.should.be.false();
try {
await this.clean();
await this.test();
} finally {
await this.clean();
}
},
);
});
Expand All @@ -35,29 +45,39 @@ describe("incus.config.device.exists", function () {
{
$ssh: ssh,
},
async function () {
await this.incus.delete({
name: "nikita-config-device-exists-2",
force: true,
});
await this.incus.init({
image: `images:${test.images.alpine}`,
name: "nikita-config-device-exists-2",
});
await this.incus.config.device({
name: "nikita-config-device-exists-2",
device: "test",
type: "unix-char",
properties: {
source: "/dev/urandom",
path: "/testrandom",
},
async function ({ registry }) {
registry.register("clean", async function () {
await this.incus.delete({
name: "nikita-config-device-exists-2",
force: true,
});
});
const { exists } = await this.incus.config.device.exists({
name: "nikita-config-device-exists-2",
device: "test",
registry.register("test", async function () {
await this.incus.init({
image: `images:${test.images.alpine}`,
name: "nikita-config-device-exists-2",
});
await this.incus.config.device({
name: "nikita-config-device-exists-2",
device: "test",
type: "unix-char",
properties: {
source: "/dev/urandom",
path: "/testrandom",
},
});
const { exists } = await this.incus.config.device.exists({
name: "nikita-config-device-exists-2",
device: "test",
});
exists.should.be.true();
});
exists.should.be.true();
try {
await this.clean();
await this.test();
} finally {
await this.clean();
}
},
);
});
Expand Down
Loading

0 comments on commit 76f549c

Please sign in to comment.