Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ts): add typing to adjudicators used in validation and mutation processing #1402

Merged
merged 73 commits into from
Dec 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
1137b84
Create full mocks of AdmissionRequest<KubernetesObject>
samayer12 Nov 7, 2024
9546791
Add return type to Admission Request adjudicators
samayer12 Nov 7, 2024
5d673d5
Address potentially undefined input to adjudicator
samayer12 Nov 7, 2024
12c8c4a
Add funciton return types
samayer12 Nov 7, 2024
cc3e810
Use consistent enum property names
samayer12 Nov 7, 2024
d94543d
Reworking types to remove typescript warnings so that I can actually …
samayer12 Nov 7, 2024
a169536
Work on resolving typing issues by using actual objects instead of pa…
samayer12 Nov 18, 2024
8300b37
use explicit imports in test file
samayer12 Nov 18, 2024
bf38e38
Fix failing tests in bindingadjudicator
samayer12 Nov 18, 2024
984660f
tidy test exports, add typing, get passing tests
samayer12 Nov 18, 2024
ecdd130
Merge branch 'main' into 1397-type-adjudicators
samayer12 Nov 18, 2024
f5c3a8d
Add typing to mismatchedEvent()
samayer12 Nov 18, 2024
2a0c025
Merge branch 'main' into 1397-type-adjudicators
samayer12 Nov 19, 2024
e7f9a5b
Update imports
samayer12 Nov 19, 2024
19a7dcd
Remove obsolete test cases now that we have typing support
samayer12 Nov 19, 2024
1eb7cde
Remove undefined return type on definedName()
samayer12 Nov 19, 2024
9aa94e9
Remove obsolete test cases now that we use typing, manage typing for …
samayer12 Nov 19, 2024
6fb930a
Update imports
samayer12 Nov 19, 2024
e7a2a86
Merge branch 'main' into 1397-type-adjudicators
samayer12 Nov 19, 2024
4c78fe0
Use regexes in test data to match typing
samayer12 Nov 20, 2024
dd2f84d
Update test case to handle typing with a null test case
samayer12 Nov 20, 2024
eaf481f
Resolve test failure for mismatchedNamespaceRegex()
samayer12 Nov 20, 2024
b790be3
Merge branch 'main' into 1397-type-adjudicators
samayer12 Nov 20, 2024
d7da7cf
Merge branch 'main' into 1397-type-adjudicators
samayer12 Nov 20, 2024
25081c2
Move default test objects to central location
samayer12 Nov 20, 2024
5cc5667
Use defaultTestObjects in bindingAdjudicators.test.ts
samayer12 Nov 20, 2024
aa24a30
Centralize more default test values
samayer12 Nov 20, 2024
dfa4eee
Merge branch 'main' into 1397-type-adjudicators
samayer12 Nov 20, 2024
2bdad5c
Undo type coversion to RexExp, use string
samayer12 Nov 21, 2024
e08e896
Remove unecessary message output sanitization
samayer12 Nov 21, 2024
786c1a2
Rearrange import and managed regex usage in tests
samayer12 Nov 21, 2024
9cc9267
Move filesystem helper to specific file
samayer12 Nov 21, 2024
a0dab61
Remove a test case obviated by the use of typing
samayer12 Nov 21, 2024
8bbcfd1
Remove kfc mock
samayer12 Nov 21, 2024
6ca317b
Use it() instead of test() to match domain-driven test naming style
samayer12 Nov 21, 2024
909e890
Rewrite test using full objects and it.each()
samayer12 Nov 21, 2024
937ce19
Remove unnecessary regex edge case now that we use typing
samayer12 Nov 21, 2024
a98e0df
Update regex to match test condition
samayer12 Nov 21, 2024
5a0753d
Restructure test format
samayer12 Nov 21, 2024
d983481
Restructure name equality test
samayer12 Nov 21, 2024
d887b53
Remove mockK8s.mockImplementation()
samayer12 Nov 21, 2024
2e44cc9
Restructure test
samayer12 Nov 21, 2024
5ac5159
Put related tests into a describe() block
samayer12 Nov 21, 2024
7c2ae10
Extract large function to new file
samayer12 Nov 21, 2024
7434ce8
Remove mocks and set return type
samayer12 Nov 21, 2024
172ebf4
Update import from cli
samayer12 Nov 21, 2024
ac8aa24
Update imports
samayer12 Nov 21, 2024
1a4e7dd
Merge branch 'main' into 1397-type-adjudicators
samayer12 Nov 21, 2024
06ea6cc
Update imports after file move
samayer12 Nov 21, 2024
0eb3f1e
Move some helper functions to deploymentChecks
samayer12 Nov 21, 2024
cb1d7bb
Remove file restructure for next commit
samayer12 Nov 21, 2024
7f98a9c
Merge branch '1397-split-helpers' into 1397-type-adjudicators
samayer12 Nov 21, 2024
8ecce94
Merge branch 'main' into 1397-type-adjudicators
samayer12 Nov 22, 2024
70c1178
Merge branch 'main' into 1397-type-adjudicators
samayer12 Nov 22, 2024
257c4b8
Undo regexp work to revisit on a separate PR
samayer12 Nov 22, 2024
54d04d6
Merge branch 'main' into 1397-type-adjudicators
cmwylie19 Dec 2, 2024
8352265
Merge branch 'main' into 1397-type-adjudicators
samayer12 Dec 4, 2024
efc0c4a
Remove max-statement suppressions
samayer12 Dec 4, 2024
a54b76d
Remove old test cases
samayer12 Dec 4, 2024
8210fad
Remove prettier suppression
samayer12 Dec 4, 2024
e6715a3
remove comment
samayer12 Dec 4, 2024
20fd796
Add more explicit typing to test code
samayer12 Dec 4, 2024
b2f9751
Remove complexity suppression
samayer12 Dec 4, 2024
66462b6
Apply sync review changes
samayer12 Dec 4, 2024
46e62a5
Remove old conditional checks now that we're typing
samayer12 Dec 4, 2024
4c267f3
Use defaultTestObject.defaultAdmissionRequest in test
samayer12 Dec 4, 2024
9505fa3
Remove nullable checks on required field
samayer12 Dec 4, 2024
c43b153
Remove describe() block wrapping
samayer12 Dec 4, 2024
7203174
Create a valid regex then provide the string definition into test cases
samayer12 Dec 4, 2024
4bd42e7
Use full variable name for clarity
samayer12 Dec 4, 2024
852ab54
Add regexr links for regexes used in tests
samayer12 Dec 4, 2024
b062a78
Merge branch 'main' into 1397-type-adjudicators
samayer12 Dec 4, 2024
51be324
Remove TODO statement
samayer12 Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove describe() block wrapping
  • Loading branch information
samayer12 committed Dec 4, 2024
commit c43b1539d36ac195577a08d88c70070a278869c6
76 changes: 37 additions & 39 deletions src/lib/filter/adjudicators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,45 +390,43 @@ describe("operationMatchesEvent", () => {

describe("mismatchedEvent", () => {
//[ Binding, AdmissionRequest, result ]
describe("when called with supported Event AND Operation types", () => {
it.each([
[{ event: Event.CREATE }, { operation: Operation.CREATE }, false],
[{ event: Event.UPDATE }, { operation: Operation.CREATE }, true],
[{ event: Event.DELETE }, { operation: Operation.CREATE }, true],
[{ event: Event.CREATE_OR_UPDATE }, { operation: Operation.CREATE }, false],
[{ event: Event.ANY }, { operation: Operation.CREATE }, false],

[{ event: Event.CREATE }, { operation: Operation.UPDATE }, true],
[{ event: Event.UPDATE }, { operation: Operation.UPDATE }, false],
[{ event: Event.DELETE }, { operation: Operation.UPDATE }, true],
[{ event: Event.CREATE_OR_UPDATE }, { operation: Operation.UPDATE }, false],
[{ event: Event.ANY }, { operation: Operation.UPDATE }, false],

[{ event: Event.CREATE }, { operation: Operation.DELETE }, true],
[{ event: Event.UPDATE }, { operation: Operation.DELETE }, true],
[{ event: Event.DELETE }, { operation: Operation.DELETE }, false],
[{ event: Event.CREATE_OR_UPDATE }, { operation: Operation.DELETE }, true],
[{ event: Event.ANY }, { operation: Operation.DELETE }, false],

[{ event: Event.CREATE }, { operation: Operation.CONNECT }, true],
[{ event: Event.UPDATE }, { operation: Operation.CONNECT }, true],
[{ event: Event.DELETE }, { operation: Operation.CONNECT }, true],
[{ event: Event.CREATE_OR_UPDATE }, { operation: Operation.CONNECT }, true],
[{ event: Event.ANY }, { operation: Operation.CONNECT }, false],
])("given binding %j and admission request %j, returns %s", (bnd, req, expected) => {
const binding: Binding = {
...defaultBinding,
event: bnd.event,
};
const request: AdmissionRequest = {
...defaultAdmissionRequest,
operation: req.operation,
};

const result = mismatchedEvent(binding, request);

expect(result).toEqual(expected);
});
it.each([
[{ event: Event.CREATE }, { operation: Operation.CREATE }, false],
[{ event: Event.UPDATE }, { operation: Operation.CREATE }, true],
[{ event: Event.DELETE }, { operation: Operation.CREATE }, true],
[{ event: Event.CREATE_OR_UPDATE }, { operation: Operation.CREATE }, false],
[{ event: Event.ANY }, { operation: Operation.CREATE }, false],

[{ event: Event.CREATE }, { operation: Operation.UPDATE }, true],
[{ event: Event.UPDATE }, { operation: Operation.UPDATE }, false],
[{ event: Event.DELETE }, { operation: Operation.UPDATE }, true],
[{ event: Event.CREATE_OR_UPDATE }, { operation: Operation.UPDATE }, false],
[{ event: Event.ANY }, { operation: Operation.UPDATE }, false],

[{ event: Event.CREATE }, { operation: Operation.DELETE }, true],
[{ event: Event.UPDATE }, { operation: Operation.DELETE }, true],
[{ event: Event.DELETE }, { operation: Operation.DELETE }, false],
[{ event: Event.CREATE_OR_UPDATE }, { operation: Operation.DELETE }, true],
[{ event: Event.ANY }, { operation: Operation.DELETE }, false],

[{ event: Event.CREATE }, { operation: Operation.CONNECT }, true],
[{ event: Event.UPDATE }, { operation: Operation.CONNECT }, true],
[{ event: Event.DELETE }, { operation: Operation.CONNECT }, true],
[{ event: Event.CREATE_OR_UPDATE }, { operation: Operation.CONNECT }, true],
[{ event: Event.ANY }, { operation: Operation.CONNECT }, false],
])("given binding %j and admission request %j, returns %s", (bnd, req, expected) => {
const binding: Binding = {
...defaultBinding,
event: bnd.event,
};
const request: AdmissionRequest = {
...defaultAdmissionRequest,
operation: req.operation,
};

const result = mismatchedEvent(binding, request);

expect(result).toEqual(expected);
});
});

Expand Down