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

[test] Unit-tests for common/k8s_utils.go (part 3 of 3) & Unit-tests and improvements for common/yaml_decoder.go #195

Merged
merged 8 commits into from
Jun 21, 2023

Conversation

art-tapin
Copy link
Contributor

@art-tapin art-tapin commented May 29, 2023

This pull request completes the unit tests for the k8s_utils.go file, addressing the remaining functions and adding additional coverage and imporvements to the yaml_decoder.go file.

Changes Made:
k8s_utils.go

  • Added unit test to ObjectKeyListDifference, ContainsObjectKey, FindObjectKey, FindDeploymentStatusCondition

yaml_decoder.go

  • Added unit tests and comment DecodeFile

Changes made to DecodeFile, see c127731

Additional Information:

Please note that the previous PRs have been merged and this PR concludes the work for issue #167.

Note also that this PR includes unmerged commits from #191

Coverage: 83.8%.

@art-tapin art-tapin marked this pull request as ready for review May 29, 2023 20:10
@art-tapin art-tapin requested a review from a team as a code owner May 29, 2023 20:10
pkg/common/yaml_decoder_test.go Outdated Show resolved Hide resolved
pkg/common/yaml_decoder_test.go Outdated Show resolved Hide resolved
art-tapin added a commit that referenced this pull request Jun 12, 2023
…mmediately (#167)

With this change, the function terminates execution upon encountering a decoding error, providing more accurate error handling. This ensures that errors are not accumulated and allows the caller to handle the error appropriately.

See: #195 (comment)
@art-tapin art-tapin force-pushed the issue167/tests_for_k8s_utils-3 branch from 87bdaaf to f2d1ee1 Compare June 15, 2023 13:47
Copy link
Collaborator

@didierofrivia didierofrivia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

Copy link
Contributor

@guicassolato guicassolato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent job, @art-tapin! Thank you! 🥇

@art-tapin art-tapin merged commit 3f21f81 into main Jun 21, 2023
@art-tapin art-tapin deleted the issue167/tests_for_k8s_utils-3 branch June 21, 2023 12:10
guicassolato added a commit that referenced this pull request Jun 21, 2023
* Build images with replaces image (#193)

* [makefile] Updating the `replaces` directive in CSV

* [gh workflow] Adding `replacesVersion` as input for workflow_dispatch

* [config] Adding default replaces operator value

* [bundle] Updated bundle

* Building the catalog with the replaces directive (#194)

* [catalog] Building the catalog with the replaces directive

* [catalog] Setting default replaces version to `0.0.0-alpha`

* [bundle] Updating config and bundle with new default release version

* upgrade operator-sdk v1.28.1

* fix verify-bundle task

* Create a ServiceMeshMember, rather than mutating the ServiceMeshMemberRoll

* Fixed access to servicemeshmember

* [test] Unit-tests for common/k8s_utils.go (part 2 of 3) (#191)

* test: Add unit-tests to StatusConditionsMarshalJSON (#167)

* test: Add unit-tests to IsOwnedBy (#167)

* refactor: Add comment to IsOwnedBy (#167)

* test: Add unit-test to GetServicePortNumber (#167)

* Update gateway-api module to v0.6.2 (#153)

* Update gateway api dep to v0.6.2
Update controller runtime
Set go version 1.19
Use github.com/onsi/ginkgo/v2 which is used by the latest version if controller-runtime (envtest).

* Update GatewayClass, Gateway and HTTPRoute to v1beta1

Since v0.6.0 GatewayClass, Gateway and HTTPRoute have moved to the
v1beta1 version of the API and support in v1alpha2 will be removed
eventually. All references to these APIS are now updated to use v1beta1.

PolicyTargetReference are still v1alpha2.

* [test] Unit-tests for common/k8s_utils.go (part 3 of 3) & Unit-tests and improvements for common/yaml_decoder.go (#195)

* test: Add test-case to TestObjectKeyListDifference (#167)

- when inputA and inputB have no common elements then return inputA as the result

* refactor: Rename tests for ObjectKeyListDifference (#167)

* test: Add unit-tests to ContainsObjectKey (#167)

* test: Add unit-tests to FindObjectKey (#167)

* test: Add unit-tests to FindDeploymentStatusCondition (#167)

* refactor: Clarify test name in TestStatusConditionsMarshalJSON (#167)

* test: Add unit-tests to DecodeFile (#167)

* refactor, improvements: DecodeFile YAML decoder (#167)

- Refactor logger initialisation and document decoding to fail fast and return errors immediately
- Enhanced empty doc check
- Add comment to the function

---------

Co-authored-by: dd di cesare <4183971+didierofrivia@users.noreply.github.com>
Co-authored-by: Eguzki Astiz Lezaun <eastizle@redhat.com>
Co-authored-by: Alex Snaps <alex@wcgw.dev>
Co-authored-by: artem_tiupin <70763601+art-tapin@users.noreply.github.com>
Co-authored-by: Michael Nairn <mnairn@redhat.com>
guicassolato added a commit that referenced this pull request Jul 14, 2023
* Build images with replaces image (#193)

* [makefile] Updating the `replaces` directive in CSV

* [gh workflow] Adding `replacesVersion` as input for workflow_dispatch

* [config] Adding default replaces operator value

* [bundle] Updated bundle

* Building the catalog with the replaces directive (#194)

* [catalog] Building the catalog with the replaces directive

* [catalog] Setting default replaces version to `0.0.0-alpha`

* [bundle] Updating config and bundle with new default release version

* upgrade operator-sdk v1.28.1

* fix verify-bundle task

* Create a ServiceMeshMember, rather than mutating the ServiceMeshMemberRoll

* Fixed access to servicemeshmember

* [test] Unit-tests for common/k8s_utils.go (part 2 of 3) (#191)

* test: Add unit-tests to StatusConditionsMarshalJSON (#167)

* test: Add unit-tests to IsOwnedBy (#167)

* refactor: Add comment to IsOwnedBy (#167)

* test: Add unit-test to GetServicePortNumber (#167)

* Update gateway-api module to v0.6.2 (#153)

* Update gateway api dep to v0.6.2
Update controller runtime
Set go version 1.19
Use github.com/onsi/ginkgo/v2 which is used by the latest version if controller-runtime (envtest).

* Update GatewayClass, Gateway and HTTPRoute to v1beta1

Since v0.6.0 GatewayClass, Gateway and HTTPRoute have moved to the
v1beta1 version of the API and support in v1alpha2 will be removed
eventually. All references to these APIS are now updated to use v1beta1.

PolicyTargetReference are still v1alpha2.

* [test] Unit-tests for common/k8s_utils.go (part 3 of 3) & Unit-tests and improvements for common/yaml_decoder.go (#195)

* test: Add test-case to TestObjectKeyListDifference (#167)

- when inputA and inputB have no common elements then return inputA as the result

* refactor: Rename tests for ObjectKeyListDifference (#167)

* test: Add unit-tests to ContainsObjectKey (#167)

* test: Add unit-tests to FindObjectKey (#167)

* test: Add unit-tests to FindDeploymentStatusCondition (#167)

* refactor: Clarify test name in TestStatusConditionsMarshalJSON (#167)

* test: Add unit-tests to DecodeFile (#167)

* refactor, improvements: DecodeFile YAML decoder (#167)

- Refactor logger initialisation and document decoding to fail fast and return errors immediately
- Enhanced empty doc check
- Add comment to the function

* [istio] Updating registerIstioExternalAuthorizer

* Reconciles also the Istio ConfigMap with the external authorizers
* If the IstioOperator CR returns an error, it continues reconciling CM

* [istio] Updating the unregisterExternalAuthorizerIstio

* With the new functionality

* [mesh config] Refactoring and testing mesh config functionality

* [makefile] Splitting local deploy in different target

* [istio] Refactoring using wrapper structs

* [go] Fixing dependencies

* [mesh config] Refactoring mesh config objects and fns

* [controller] Fixing registering logic

* Still relying on the istio CRD being installed. If not, means no istio
* If it's 404, means it's installed other way than it's operator
* If any other error happens, istio is installed, but an error occurred

* [controller] Refactoring istio installation process

* Added ENV for CM name

* [refactor] Using apierrors.IsNotFound instead of crafting the error msg

* kind: bump to 0.20.0 and pin image to kindest/node:v1.27.3 (#209)

* Upgrade Authorino and Authorino Operator to latest (#211)

* Authorino v0.14.0
* Authorino Operator v0.8.0

* workflow: use go1.19 to align with go.mod go version used (#213)

* workflow: use go1.19 to align with go.mod go version used

* doc: fix operator-sdk & kind versions used for development

---------

Co-authored-by: dd di cesare <4183971+didierofrivia@users.noreply.github.com>
Co-authored-by: Eguzki Astiz Lezaun <eastizle@redhat.com>
Co-authored-by: Alex Snaps <alex@wcgw.dev>
Co-authored-by: artem_tiupin <70763601+art-tapin@users.noreply.github.com>
Co-authored-by: Michael Nairn <mnairn@redhat.com>
Co-authored-by: dd di cesare <didi@posteo.net>
Co-authored-by: Kevin Fan <chfan@redhat.com>
KevFan pushed a commit to KevFan/kuadrant-operator that referenced this pull request Aug 10, 2023
* Build images with replaces image (Kuadrant#193)

* [makefile] Updating the `replaces` directive in CSV

* [gh workflow] Adding `replacesVersion` as input for workflow_dispatch

* [config] Adding default replaces operator value

* [bundle] Updated bundle

* Building the catalog with the replaces directive (Kuadrant#194)

* [catalog] Building the catalog with the replaces directive

* [catalog] Setting default replaces version to `0.0.0-alpha`

* [bundle] Updating config and bundle with new default release version

* upgrade operator-sdk v1.28.1

* fix verify-bundle task

* Create a ServiceMeshMember, rather than mutating the ServiceMeshMemberRoll

* Fixed access to servicemeshmember

* [test] Unit-tests for common/k8s_utils.go (part 2 of 3) (Kuadrant#191)

* test: Add unit-tests to StatusConditionsMarshalJSON (Kuadrant#167)

* test: Add unit-tests to IsOwnedBy (Kuadrant#167)

* refactor: Add comment to IsOwnedBy (Kuadrant#167)

* test: Add unit-test to GetServicePortNumber (Kuadrant#167)

* Update gateway-api module to v0.6.2 (Kuadrant#153)

* Update gateway api dep to v0.6.2
Update controller runtime
Set go version 1.19
Use github.com/onsi/ginkgo/v2 which is used by the latest version if controller-runtime (envtest).

* Update GatewayClass, Gateway and HTTPRoute to v1beta1

Since v0.6.0 GatewayClass, Gateway and HTTPRoute have moved to the
v1beta1 version of the API and support in v1alpha2 will be removed
eventually. All references to these APIS are now updated to use v1beta1.

PolicyTargetReference are still v1alpha2.

* [test] Unit-tests for common/k8s_utils.go (part 3 of 3) & Unit-tests and improvements for common/yaml_decoder.go (Kuadrant#195)

* test: Add test-case to TestObjectKeyListDifference (Kuadrant#167)

- when inputA and inputB have no common elements then return inputA as the result

* refactor: Rename tests for ObjectKeyListDifference (Kuadrant#167)

* test: Add unit-tests to ContainsObjectKey (Kuadrant#167)

* test: Add unit-tests to FindObjectKey (Kuadrant#167)

* test: Add unit-tests to FindDeploymentStatusCondition (Kuadrant#167)

* refactor: Clarify test name in TestStatusConditionsMarshalJSON (Kuadrant#167)

* test: Add unit-tests to DecodeFile (Kuadrant#167)

* refactor, improvements: DecodeFile YAML decoder (Kuadrant#167)

- Refactor logger initialisation and document decoding to fail fast and return errors immediately
- Enhanced empty doc check
- Add comment to the function

---------

Co-authored-by: dd di cesare <4183971+didierofrivia@users.noreply.github.com>
Co-authored-by: Eguzki Astiz Lezaun <eastizle@redhat.com>
Co-authored-by: Alex Snaps <alex@wcgw.dev>
Co-authored-by: artem_tiupin <70763601+art-tapin@users.noreply.github.com>
Co-authored-by: Michael Nairn <mnairn@redhat.com>
KevFan pushed a commit to KevFan/kuadrant-operator that referenced this pull request Aug 14, 2023
* Build images with replaces image (Kuadrant#193)

* [makefile] Updating the `replaces` directive in CSV

* [gh workflow] Adding `replacesVersion` as input for workflow_dispatch

* [config] Adding default replaces operator value

* [bundle] Updated bundle

* Building the catalog with the replaces directive (Kuadrant#194)

* [catalog] Building the catalog with the replaces directive

* [catalog] Setting default replaces version to `0.0.0-alpha`

* [bundle] Updating config and bundle with new default release version

* upgrade operator-sdk v1.28.1

* fix verify-bundle task

* Create a ServiceMeshMember, rather than mutating the ServiceMeshMemberRoll

* Fixed access to servicemeshmember

* [test] Unit-tests for common/k8s_utils.go (part 2 of 3) (Kuadrant#191)

* test: Add unit-tests to StatusConditionsMarshalJSON (Kuadrant#167)

* test: Add unit-tests to IsOwnedBy (Kuadrant#167)

* refactor: Add comment to IsOwnedBy (Kuadrant#167)

* test: Add unit-test to GetServicePortNumber (Kuadrant#167)

* Update gateway-api module to v0.6.2 (Kuadrant#153)

* Update gateway api dep to v0.6.2
Update controller runtime
Set go version 1.19
Use github.com/onsi/ginkgo/v2 which is used by the latest version if controller-runtime (envtest).

* Update GatewayClass, Gateway and HTTPRoute to v1beta1

Since v0.6.0 GatewayClass, Gateway and HTTPRoute have moved to the
v1beta1 version of the API and support in v1alpha2 will be removed
eventually. All references to these APIS are now updated to use v1beta1.

PolicyTargetReference are still v1alpha2.

* [test] Unit-tests for common/k8s_utils.go (part 3 of 3) & Unit-tests and improvements for common/yaml_decoder.go (Kuadrant#195)

* test: Add test-case to TestObjectKeyListDifference (Kuadrant#167)

- when inputA and inputB have no common elements then return inputA as the result

* refactor: Rename tests for ObjectKeyListDifference (Kuadrant#167)

* test: Add unit-tests to ContainsObjectKey (Kuadrant#167)

* test: Add unit-tests to FindObjectKey (Kuadrant#167)

* test: Add unit-tests to FindDeploymentStatusCondition (Kuadrant#167)

* refactor: Clarify test name in TestStatusConditionsMarshalJSON (Kuadrant#167)

* test: Add unit-tests to DecodeFile (Kuadrant#167)

* refactor, improvements: DecodeFile YAML decoder (Kuadrant#167)

- Refactor logger initialisation and document decoding to fail fast and return errors immediately
- Enhanced empty doc check
- Add comment to the function

---------

Co-authored-by: dd di cesare <4183971+didierofrivia@users.noreply.github.com>
Co-authored-by: Eguzki Astiz Lezaun <eastizle@redhat.com>
Co-authored-by: Alex Snaps <alex@wcgw.dev>
Co-authored-by: artem_tiupin <70763601+art-tapin@users.noreply.github.com>
Co-authored-by: Michael Nairn <mnairn@redhat.com>
KevFan pushed a commit to KevFan/kuadrant-operator that referenced this pull request Aug 14, 2023
* Build images with replaces image (Kuadrant#193)

* [makefile] Updating the `replaces` directive in CSV

* [gh workflow] Adding `replacesVersion` as input for workflow_dispatch

* [config] Adding default replaces operator value

* [bundle] Updated bundle

* Building the catalog with the replaces directive (Kuadrant#194)

* [catalog] Building the catalog with the replaces directive

* [catalog] Setting default replaces version to `0.0.0-alpha`

* [bundle] Updating config and bundle with new default release version

* upgrade operator-sdk v1.28.1

* fix verify-bundle task

* Create a ServiceMeshMember, rather than mutating the ServiceMeshMemberRoll

* Fixed access to servicemeshmember

* [test] Unit-tests for common/k8s_utils.go (part 2 of 3) (Kuadrant#191)

* test: Add unit-tests to StatusConditionsMarshalJSON (Kuadrant#167)

* test: Add unit-tests to IsOwnedBy (Kuadrant#167)

* refactor: Add comment to IsOwnedBy (Kuadrant#167)

* test: Add unit-test to GetServicePortNumber (Kuadrant#167)

* Update gateway-api module to v0.6.2 (Kuadrant#153)

* Update gateway api dep to v0.6.2
Update controller runtime
Set go version 1.19
Use github.com/onsi/ginkgo/v2 which is used by the latest version if controller-runtime (envtest).

* Update GatewayClass, Gateway and HTTPRoute to v1beta1

Since v0.6.0 GatewayClass, Gateway and HTTPRoute have moved to the
v1beta1 version of the API and support in v1alpha2 will be removed
eventually. All references to these APIS are now updated to use v1beta1.

PolicyTargetReference are still v1alpha2.

* [test] Unit-tests for common/k8s_utils.go (part 3 of 3) & Unit-tests and improvements for common/yaml_decoder.go (Kuadrant#195)

* test: Add test-case to TestObjectKeyListDifference (Kuadrant#167)

- when inputA and inputB have no common elements then return inputA as the result

* refactor: Rename tests for ObjectKeyListDifference (Kuadrant#167)

* test: Add unit-tests to ContainsObjectKey (Kuadrant#167)

* test: Add unit-tests to FindObjectKey (Kuadrant#167)

* test: Add unit-tests to FindDeploymentStatusCondition (Kuadrant#167)

* refactor: Clarify test name in TestStatusConditionsMarshalJSON (Kuadrant#167)

* test: Add unit-tests to DecodeFile (Kuadrant#167)

* refactor, improvements: DecodeFile YAML decoder (Kuadrant#167)

- Refactor logger initialisation and document decoding to fail fast and return errors immediately
- Enhanced empty doc check
- Add comment to the function

---------

Co-authored-by: dd di cesare <4183971+didierofrivia@users.noreply.github.com>
Co-authored-by: Eguzki Astiz Lezaun <eastizle@redhat.com>
Co-authored-by: Alex Snaps <alex@wcgw.dev>
Co-authored-by: artem_tiupin <70763601+art-tapin@users.noreply.github.com>
Co-authored-by: Michael Nairn <mnairn@redhat.com>
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.

Improve test coverage for package common
4 participants