Skip to content

Commit

Permalink
chore: remove usage of regex matches in filter test condition (#1869)
Browse files Browse the repository at this point in the history
#1779)

## Description

...

End to End Test:  <!-- if applicable -->  
(See [Pepr Excellent
Examples](https://github.com/defenseunicorns/pepr-excellent-examples))

## Related Issue

Fixes #1779


## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Other (security config, docs update, etc)

## Checklist before merging
- [x] Unit,
[Journey](https://github.com/defenseunicorns/pepr/tree/main/journey),
[E2E Tests](https://github.com/defenseunicorns/pepr-excellent-examples),
[docs](https://github.com/defenseunicorns/pepr/tree/main/docs),
[adr](https://github.com/defenseunicorns/pepr/tree/main/adr) added or
updated as needed
- [x] [Contributor Guide
Steps](https://docs.pepr.dev/main/contribute/#submitting-a-pull-request)
followed

Co-authored-by: Case Wylie <[email protected]>
  • Loading branch information
tamirazrab and cmwylie19 authored Feb 25, 2025
1 parent 42cd8de commit 00b120b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/lib/filter/filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ describe("shouldSkipRequest", () => {
});

const pod = AdmissionRequestCreatePod();

expect(shouldSkipRequest(binding, pod, [])).toMatch(
/Ignoring Admission Callback: Binding defines name regex '.*' but Object carries '.*'./,
/Ignoring Admission Callback: Binding defines name regex '\^default\$' but Object carries 'cool-name-podinfo-66bbff7cf4-fwhl2'./,
);
});

Expand All @@ -160,7 +161,7 @@ describe("shouldSkipRequest", () => {

const pod = AdmissionRequestDeletePod();
expect(shouldSkipRequest(binding, pod, [])).toMatch(
/Ignoring Admission Callback: Binding defines name regex '.*' but Object carries '.*'./,
/Ignoring Admission Callback: Binding defines name regex '\^default\$' but Object carries 'cool-name-podinfo-66bbff7cf4-fwhl2'./,
);
});

Expand Down Expand Up @@ -192,7 +193,7 @@ describe("shouldSkipRequest", () => {

const pod = AdmissionRequestCreatePod();
expect(shouldSkipRequest(binding, pod, [])).toMatch(
/Ignoring Admission Callback: Binding defines namespace regexes '.*' but Object carries '.*'./,
/Ignoring Admission Callback: Binding defines namespace regexes '\["\^argo"\]' but Object carries 'helm-releasename'./,
);
});

Expand All @@ -204,7 +205,7 @@ describe("shouldSkipRequest", () => {

const pod = AdmissionRequestDeletePod();
expect(shouldSkipRequest(binding, pod, [])).toMatch(
/Ignoring Admission Callback: Binding defines namespace regexes '.*' but Object carries '.*'./,
/Ignoring Admission Callback: Binding defines namespace regexes '\["\^argo"\]' but Object carries 'helm-releasename'./,
);
});

Expand All @@ -226,7 +227,7 @@ describe("shouldSkipRequest", () => {

const pod = AdmissionRequestDeletePod();
expect(shouldSkipRequest(binding, pod, [])).toMatch(
/Ignoring Admission Callback: Binding defines name '.*' but Object carries '.*'./,
/Ignoring Admission Callback: Binding defines name 'bleh' but Object carries 'cool-name-podinfo-66bbff7cf4-fwhl2'./,
);
});

Expand All @@ -239,7 +240,7 @@ describe("shouldSkipRequest", () => {
const pod = AdmissionRequestCreatePod();

expect(shouldSkipRequest(binding, pod, [])).toMatch(
/Ignoring Admission Callback: Binding defines kind '.*' but Request declares '.*'./,
/Ignoring Admission Callback: Binding defines kind 'Nope' but Request declares 'Pod'./,
);
});

Expand All @@ -252,7 +253,7 @@ describe("shouldSkipRequest", () => {
const pod = AdmissionRequestCreatePod();

expect(shouldSkipRequest(binding, pod, [])).toMatch(
/Ignoring Admission Callback: Binding defines group '.*' but Request declares '.*'./,
/Ignoring Admission Callback: Binding defines group 'Nope' but Request declares ''./,
);
});

Expand All @@ -265,7 +266,7 @@ describe("shouldSkipRequest", () => {
const pod = AdmissionRequestCreatePod();

expect(shouldSkipRequest(binding, pod, [])).toMatch(
/Ignoring Admission Callback: Binding defines version '.*' but Request declares '.*'./,
/Ignoring Admission Callback: Binding defines version 'Nope' but Request declares 'v1'./,
);
});

Expand Down Expand Up @@ -298,7 +299,7 @@ describe("shouldSkipRequest", () => {
const pod = AdmissionRequestCreatePod();

expect(shouldSkipRequest(binding, pod, ["bleh", "bleh2"])).toMatch(
/Ignoring Admission Callback: Object carries namespace '.*' but namespaces allowed by Capability are '.*'./,
/Ignoring Admission Callback: Object carries namespace 'helm-releasename' but namespaces allowed by Capability are '\["bleh","bleh2"\]'\./,
);
});

Expand All @@ -311,7 +312,7 @@ describe("shouldSkipRequest", () => {
const pod = AdmissionRequestCreatePod();

expect(shouldSkipRequest(binding, pod, [])).toMatch(
/Ignoring Admission Callback: Binding defines namespaces '.*' but Object carries '.*'./,
/Ignoring Admission Callback: Binding defines namespaces '\["bleh"\]' but Object carries 'helm-releasename'./,
);
});

Expand Down Expand Up @@ -339,7 +340,7 @@ describe("shouldSkipRequest", () => {
const pod = AdmissionRequestCreatePod();

expect(shouldSkipRequest(binding, pod, [])).toMatch(
/Ignoring Admission Callback: Binding defines labels '.*' but Object carries '.*'./,
/Ignoring Admission Callback: Binding defines labels '\{"foo":"bar"\}' but Object carries '\{"app\.kubernetes\.io\/name":"cool-name-podinfo","pod-template-hash":"66bbff7cf4","zarf-agent":"patched","test-op":"create"\}'.*/,
);
});

Expand Down Expand Up @@ -378,7 +379,7 @@ describe("shouldSkipRequest", () => {
const pod = AdmissionRequestCreatePod();

expect(shouldSkipRequest(binding, pod, [])).toMatch(
/Ignoring Admission Callback: Binding defines annotations '.*' but Object carries '.*'./,
/Ignoring Admission Callback: Binding defines annotations '\{"foo":"bar"\}' but Object carries '\{"prometheus\.io\/port":"9898","prometheus\.io\/scrape":"true"\}'./,
);
});

Expand Down

0 comments on commit 00b120b

Please sign in to comment.