Skip to content

Commit ed8feac

Browse files
test: add test cases for label order independence in exactMatch
Signed-off-by: Brend Smits <brend.smits@philips.com> Co-authored-by: Stuart Pearson <stuart.pearson@philips.com>
1 parent 7f4238f commit ed8feac

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lambdas/functions/webhook/src/runners/dispatch.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,24 @@ describe('Dispatcher', () => {
237237
const runnerLabels = [['self-hosted', 'linux', 'on-demand']];
238238
expect(canRunJob(workflowLabels, runnerLabels, true)).toBe(true);
239239
});
240+
241+
it('should match with exactMatch=true when labels are in different order.', () => {
242+
const workflowLabels = ['linux', 'self-hosted', 'x64'];
243+
const runnerLabels = [['self-hosted', 'linux', 'x64']];
244+
expect(canRunJob(workflowLabels, runnerLabels, true)).toBe(true);
245+
});
246+
247+
it('should match with exactMatch=true when labels are completely shuffled.', () => {
248+
const workflowLabels = ['x64', 'ubuntu-latest', 'self-hosted', 'linux'];
249+
const runnerLabels = [['self-hosted', 'linux', 'x64', 'ubuntu-latest']];
250+
expect(canRunJob(workflowLabels, runnerLabels, true)).toBe(true);
251+
});
252+
253+
it('should match with exactMatch=false when labels are in different order.', () => {
254+
const workflowLabels = ['gpu', 'self-hosted'];
255+
const runnerLabels = [['self-hosted', 'gpu']];
256+
expect(canRunJob(workflowLabels, runnerLabels, false)).toBe(true);
257+
});
240258
});
241259
});
242260

0 commit comments

Comments
 (0)