Skip to content

Commit

Permalink
Add unit test for max size
Browse files Browse the repository at this point in the history
  • Loading branch information
hansott committed Dec 6, 2024
1 parent 29736ee commit 1cf5380
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions library/agent/Hostnames.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,36 @@ t.test("it works", async () => {
hostnames.clear();
t.same(hostnames.asArray(), []);
});

t.test("it respects max size", async () => {
const hostnames = new Hostnames(2);
hostnames.add("aikido.dev", 1);
hostnames.add("aikido.dev", 2);

t.same(hostnames.asArray(), [
{ hostname: "aikido.dev", port: 1 },
{ hostname: "aikido.dev", port: 2 },
]);

hostnames.add("aikido.dev", 3);
hostnames.add("aikido.dev", 4);

t.same(hostnames.asArray(), [
{ hostname: "aikido.dev", port: 3 },
{ hostname: "aikido.dev", port: 4 },
]);

hostnames.add("google.com", 1);

t.same(hostnames.asArray(), [
{ hostname: "aikido.dev", port: 4 },
{ hostname: "google.com", port: 1 },
]);

hostnames.add("google.com", 2);

t.same(hostnames.asArray(), [
{ hostname: "google.com", port: 1 },
{ hostname: "google.com", port: 2 },
]);
});

0 comments on commit 1cf5380

Please sign in to comment.