Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schleyfox committed Nov 16, 2023
1 parent 4f93728 commit aab7778
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/test/client_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1747,3 +1747,58 @@ tap.only("VersionAllSomeFailed", function (t) {
assertor(err);
});
});

test("VersionAllWithErrorsSuccessful", function (t) {
const dummyServer1 = makeDummyVersionServer(t, "dummyServer1", "1.0.0");
const dummyServer2 = makeDummyVersionServer(t, "dummyServer2", "2.0.0");
const dummyServer3 = makeDummyVersionServer(t, "dummyServer3", "3.0.0");

const client = makeClient([dummyServer1, dummyServer2, dummyServer3]);
const assertor = function (
val?: Record<string, {version?: string | Buffer | null, error?: Error}> | null
) {
t.deepEqual(
{
"dummyServer1:undefined": { version: "1.0.0" },
"dummyServer2:undefined": { version: "2.0.0" },
"dummyServer3:undefined": { version: "3.0.0" },
},
val
);
};

return client.versionAllWithErrors().then(function (res) {
assertor(res.values);
});
});

tap.only("VersionAllWithErrorsSomeFailed", function (t) {
const dummyServer1 = makeDummyVersionServer(t, "dummyServer1", "1.0.0");
const dummyServer2 = makeDummyVersionServer(t, "dummyServer2", "2.0.0");
dummyServer2.write = function () {
dummyServer2.error({
name: "ErrorName",
message: "This is an expected error.",
});
};
const dummyServer3 = makeDummyVersionServer(t, "dummyServer3", "3.0.0");

const client = makeClient([dummyServer1, dummyServer2, dummyServer3]);
const assertor = function (
val?: Record<string, {version?: string | Buffer | null, error?: Error}> | null
) {
t.deepEqual(
{
"dummyServer1:undefined": { version: "1.0.0" },
"dummyServer2:undefined": { error: { name: "ErrorName", message: "This is an expected error." } },
"dummyServer3:undefined": { version: "3.0.0" },
},
val
);
};


return client.versionAllWithErrors().then(function (res) {
assertor(res.values);
});
});

0 comments on commit aab7778

Please # to comment.