Skip to content

Commit f15e81a

Browse files
committed
test(usage): cover skipped-record warnings across hosts
1 parent a4c88ff commit f15e81a

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

‎packages/shared/src/usageFormat.test.ts‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,37 @@ describe("usage source messages", () => {
3434
]);
3535
});
3636

37-
it("counts equal warnings from distinct sources but the same source only once", () => {
37+
it.each([
38+
{ first: 1, second: 1, total: 2 },
39+
{ first: 1, second: 11, total: 12 },
40+
])(
41+
"combines hosts reporting $first and $second skipped records once per source",
42+
({ first, second, total }) => {
43+
const source = malformedSource(first);
44+
const otherHost = malformedSource(second, {
45+
fingerprint: { ...source.fingerprint, hostId: "other-demo-host" },
46+
});
47+
48+
expect(usageSourceMessages([source, source, otherHost, otherHost])).toEqual([
49+
`${total} malformed or inconsistent usage record(s) were skipped; usage may be incomplete.`,
50+
]);
51+
expect(usageSourceMessages([source, source])).toEqual([
52+
`${first} malformed or inconsistent usage record(s) were skipped; usage may be incomplete.`,
53+
]);
54+
expect(usageSourceMessages([otherHost, otherHost])).toEqual([
55+
`${second} malformed or inconsistent usage record(s) were skipped; usage may be incomplete.`,
56+
]);
57+
},
58+
);
59+
60+
it("keeps different machines with the same hostname and home path distinct", () => {
3861
const source = malformedSource(1);
39-
const otherHost = malformedSource(1, {
40-
fingerprint: { ...source.fingerprint, hostId: "other-demo-host" },
62+
const otherMachine = malformedSource(11, {
63+
fingerprint: { ...source.fingerprint, volumeId: "other-demo-volume" },
4164
});
4265

43-
expect(usageSourceMessages([source, source, otherHost])).toEqual([
44-
"2 malformed or inconsistent usage record(s) were skipped; usage may be incomplete.",
66+
expect(usageSourceMessages([source, otherMachine])).toEqual([
67+
"12 malformed or inconsistent usage record(s) were skipped; usage may be incomplete.",
4568
]);
4669
});
4770

0 commit comments

Comments
 (0)