Skip to content

test(): add unit tests for common.go (0% ➝ 100% coverage) #74

Open
yuvraj-kolkar17 wants to merge 9 commits intokubeslice:masterfrom
yuvraj-kolkar17:test/add-cmd-common-tests
Open

test(): add unit tests for common.go (0% ➝ 100% coverage) #74
yuvraj-kolkar17 wants to merge 9 commits intokubeslice:masterfrom
yuvraj-kolkar17:test/add-cmd-common-tests

Conversation

@yuvraj-kolkar17
Copy link

@yuvraj-kolkar17 yuvraj-kolkar17 commented Jul 28, 2025

Description

Added comprehensive unit tests for the cmd/common.go file to achieve 100% test coverage.
This ensures the core utility functions in the common.go file behave as expected across various edge cases.

Part of #46

How Has This Been Tested?

go test ./cmd -coverprofile=coverage.out
go tool cover -func=coverage.out

Before vs After:

Before After

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit test cases.

Does this PR introduce a breaking change?


yuvraj-kolkar17 and others added 5 commits July 28, 2025 22:24
Signed-off-by: yuvraj Kolkar <kolkaryuvraj2@gmail.com>
Signed-off-by: yuvraj Kolkar <144676738+yuvraj-kolkar17@users.noreply.github.com>
Signed-off-by: yuvraj Kolkar <144676738+yuvraj-kolkar17@users.noreply.github.com>
Signed-off-by: yuvraj Kolkar <144676738+yuvraj-kolkar17@users.noreply.github.com>
Signed-off-by: yuvraj Kolkar <144676738+yuvraj-kolkar17@users.noreply.github.com>
@yuvraj-kolkar17
Copy link
Author

yuvraj-kolkar17 commented Jul 28, 2025

Hi @priyank-upadhyay @narmidm @gourishkb @Rahul-D78

Can you please review this PR !

@yuvraj-kolkar17 yuvraj-kolkar17 changed the title test(): added 0% to 100% unit test coverage for cmd/common.go test(): Added100% unit test coverage for cmd/common.go Jul 28, 2025
@yuvraj-kolkar17 yuvraj-kolkar17 changed the title test(): Added100% unit test coverage for cmd/common.go test(): Added 100% unit test coverage for cmd/common.go Jul 28, 2025
@narmidm narmidm assigned narmidm and yuvraj-kolkar17 and unassigned narmidm Jul 28, 2025
@narmidm narmidm self-requested a review July 28, 2025 20:24
@yuvraj-kolkar17
Copy link
Author

yuvraj-kolkar17 commented Jul 28, 2025

Hello @narmidm sir, should I write unit tests, integration tests, or both for the other files in /cmd/? or shift to the /pkg?
Also, PTAL and review this PR and #75 when you have a chance. Thanks a lot!

@yuvraj-kolkar17 yuvraj-kolkar17 changed the title test(): Added 100% unit test coverage for cmd/common.go test(): add unit tests for common.go (0% ➝ 100% coverage) Jul 31, 2025
@Alokzh
Copy link
Contributor

Alokzh commented Sep 19, 2025

Hello @yuvraj-kolkar17
This PR looks good ! Just two small suggestions:

  1. Can you please remove TestGlobalVariables ? It modifies global state which can cause issues & I think global variables don't really need testing since they're just declarations.
  2. Also can you please consider adding t.Parallel() for faster test execution.

Thanks !

@yuvraj-kolkar17
Copy link
Author

yuvraj-kolkar17 commented Sep 20, 2025

Hello @yuvraj-kolkar17 This PR looks good ! Just two small suggestions:

  1. Can you please remove TestGlobalVariables ? It modifies global state which can cause issues & I think global variables don't really need testing since they're just declarations.
  2. Also can you please consider adding t.Parallel() for faster test execution.

Thanks !

ok i will do that @Alokzh

@yuvraj-kolkar17
Copy link
Author

yuvraj-kolkar17 commented Sep 24, 2025

@Alokzh PTAL
I’ve just updated the changes on the test/add-cmd-common-tests branch.
Are there any other areas where I could help out?

@Alokzh
Copy link
Contributor

Alokzh commented Sep 25, 2025

Thnx @yuvraj-kolkar17
Can you please sign off the commit

Signed-off-by: yuvraj Kolkar <kolkaryuvraj2@gmail.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.

3 participants