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

Mock DNS package, extend testing (1/3) #630

Merged
merged 1 commit into from
Oct 2, 2021
Merged

Conversation

kuritka
Copy link
Collaborator

@kuritka kuritka commented Sep 29, 2021

decided to expand the tests for the DNS package (the current coverage is only 20%).

Consequence:

  • I had to split the creation of ObjectManager and infoblox provider
  • FakeInfoblox client is no longer needed - we have mocks (cleaner design separates test code from execution code)
  • I don't need to keep the Overrides.FakeInfoblox switch in the config - I'll remove it in the next PR (2/3)
  • We can test more - in the following PR (3/3) I will extend the DNS package testing
  • I moved functions checkZoneDelegated, filterOutDelegateTo from ib-client.go to infoblox-client.go.
    IBX provider constructor accepts ObjectManager interface now so I had to extend factory and fix several tests.

To test the change, I created one test TestCreateZoneDelegationForExternalDNS and generated the necessary mocks.

We currently have around 40% coverage but as said, will add new tests in following PR (3/3).

Signed-off-by: kuritka [email protected]

decided to expand the tests for the DNS package (the current coverage is only 20%).

Consequence:
- I had to split the creation of ObjectManager and infoblox provider
- FakeInfoblox client is no longer needed - we have mocks (cleaner design separates test code from execution code)
- I don't need to keep the Overrides.FakeInfoblox switch in the config - I'll remove it in the next PR
- We can test more - in the next PR I will extend the DNS package testing
- I moved functions `checkZoneDelegated`, `filterOutDelegateTo` from `ib-client.go` to `infoblox-client.go`.
  IBX provider constructor accepts ObjectManager interface now so I had to extend factory and fix several tests.

To test the change, I created one test `TestCreateZoneDelegationForExternalDNS` and generated the necessary mocks.

We currently have around 40% coverage but as said, will add new tests in following PR.

Signed-off-by: kuritka <[email protected]>
@kuritka kuritka force-pushed the ibx-provider-split2 branch from c1c2178 to cf72e5e Compare September 30, 2021 07:41
@kuritka kuritka changed the title Mock DNS package, extend testing Mock DNS package, extend testing (1/3) Sep 30, 2021
kuritka added a commit that referenced this pull request Sep 30, 2021
This is a follow-up PR to #630 (1/3), do not review until #630 is moderated

Everything is now being mocked up, there is no need to distinguish between local and production infoblox.
Bool switch no longer makes sense, removing

Signed-off-by: kuritka <[email protected]>
kuritka added a commit that referenced this pull request Sep 30, 2021
This PR is dependent on #630, please review this PR when #630 is merged.

Thanks to the redesign and mock I can test what is going on inside the big functions in the DNS package. I have written several tests that create/update the DNS record and assert values at runtime (not just the error the function returns). I managed to achieve 62% coverage. The rest are mostly constructor functions, single-line functions that call the assistant (this is more about testing the assistant package).

Signed-off-by: kuritka <[email protected]>
kuritka added a commit that referenced this pull request Sep 30, 2021
This is a follow-up PR to #630 (1/3), do not review until #630 is merged

Everything is now being mocked up, there is no need to distinguish between local and production infoblox.
Bool switch no longer makes sense, removing

Signed-off-by: kuritka <[email protected]>
kuritka added a commit that referenced this pull request Sep 30, 2021
This is a follow-up PR to #630 (1/3), do not review until #630 is merged.

Thanks to the ntroducing mocks I can test what is going on inside the large functions in the DNS package.
I have written several tests that create/update the DNS record and assert values at runtime (not just asserting the error the function returns).
I managed to achieve 62% coverage. The uncovered are mostly constructor functions, single-line functions that call the assistant package directly (this is more about testing the assistant package).

Signed-off-by: kuritka <[email protected]>
kuritka added a commit that referenced this pull request Sep 30, 2021
This is a follow-up PR to #630 (1/3), do not review until #630 is merged.

Thanks to the ntroducing mocks I can test what is going on inside the large functions in the DNS package.
I have written several tests that create/update the DNS record and assert values at runtime (not just asserting the error the function returns).
I managed to achieve 62% coverage. The uncovered are mostly constructor functions, single-line functions that call the assistant package directly (this is more about testing the assistant package).

Signed-off-by: kuritka <[email protected]>
@kuritka kuritka merged commit 8e9d3cb into master Oct 2, 2021
@kuritka kuritka deleted the ibx-provider-split2 branch October 2, 2021 13:14
kuritka added a commit that referenced this pull request Oct 2, 2021
This is a follow-up PR to #630 (1/3), do not review until #630 is merged.

Thanks to the ntroducing mocks I can test what is going on inside the large functions in the DNS package.
I have written several tests that create/update the DNS record and assert values at runtime (not just asserting the error the function returns).
I managed to achieve 62% coverage. The uncovered are mostly constructor functions, single-line functions that call the assistant package directly (this is more about testing the assistant package).

Signed-off-by: kuritka <[email protected]>
kuritka added a commit that referenced this pull request Oct 2, 2021
This is a follow-up PR to #630 (1/3), do not review until #630 is merged

Everything is now being mocked up, there is no need to distinguish between local and production infoblox.
Bool switch no longer makes sense, removing

Signed-off-by: kuritka <[email protected]>
kuritka added a commit that referenced this pull request Oct 2, 2021
This is a follow-up PR to #630 (1/3), do not review until #630 is merged

Everything is now being mocked up, there is no need to distinguish between local and production infoblox.
Bool switch no longer makes sense, removing

Signed-off-by: kuritka <[email protected]>
kuritka added a commit that referenced this pull request Oct 4, 2021
This is a follow-up PR to #630 (1/3), do not review until #630 is merged.

Thanks to the ntroducing mocks I can test what is going on inside the large functions in the DNS package.
I have written several tests that create/update the DNS record and assert values at runtime (not just asserting the error the function returns).
I managed to achieve 62% coverage. The uncovered are mostly constructor functions, single-line functions that call the assistant package directly (this is more about testing the assistant package).

Signed-off-by: kuritka <[email protected]>
kuritka added a commit that referenced this pull request Oct 4, 2021
This is a follow-up PR to #630 (1/3), do not review until #630 is merged.

Thanks to the ntroducing mocks I can test what is going on inside the large functions in the DNS package.
I have written several tests that create/update the DNS record and assert values at runtime (not just asserting the error the function returns).
I managed to achieve 62% coverage. The uncovered are mostly constructor functions, single-line functions that call the assistant package directly (this is more about testing the assistant package).

Signed-off-by: kuritka <[email protected]>
kuritka added a commit that referenced this pull request Oct 4, 2021
This is a follow-up PR to #630 (1/3), do not review until #630 is merged.

Thanks to the ntroducing mocks I can test what is going on inside the large functions in the DNS package.
I have written several tests that create/update the DNS record and assert values at runtime (not just asserting the error the function returns).
I managed to achieve 62% coverage. The uncovered are mostly constructor functions, single-line functions that call the assistant package directly (this is more about testing the assistant package).

Signed-off-by: kuritka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants