Skip to content

test: Add test cases for discovery.go#81

Open
gaurab-khanal wants to merge 1 commit into
kubestellar:mainfrom
gaurab-khanal:test_discovery
Open

test: Add test cases for discovery.go#81
gaurab-khanal wants to merge 1 commit into
kubestellar:mainfrom
gaurab-khanal:test_discovery

Conversation

@gaurab-khanal
Copy link
Copy Markdown
Contributor

Description

This PR adds test cases for discovery.go.

@gaurab-khanal
Copy link
Copy Markdown
Contributor Author

@Rupam-It I got one error here for TestBuildClusterClient.

--- FAIL: TestBuildClusterClient (0.00s)
    --- FAIL: TestBuildClusterClient/exists_kubeconfig_and_context_override_wds1 (0.00s)
        discovery_test.go:200: Expected ctxName to be "wds1", but got "test-context"
        discovery_test.go:203: Expected clusterName to be "wds1-cluster", but got "test-cluster"

It seems like

ctxName := rawCfg.CurrentContext 

doesn't returns override context.

Reference: https://github.com/kubestellar/kubectl-plugin/blob/main/pkg/cluster/discovery.go#L136

Can't we just return overrides.CurrentContext as the ctxName.
Reference: https://github.com/kubestellar/kubectl-plugin/blob/main/pkg/cluster/discovery.go#L102C3-L102C27

@gaurab-khanal
Copy link
Copy Markdown
Contributor Author

@Rupam-It Any updates for this?

Copy link
Copy Markdown
Contributor

@Rupam-It Rupam-It left a comment

Choose a reason for hiding this comment

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

Hii @gaurab-khanal can you please describe what the problem with ctx?

@gaurab-khanal
Copy link
Copy Markdown
Contributor Author

@Rupam-It
Copy link
Copy Markdown
Contributor

Rupam-It commented Nov 3, 2025

@gaurab-khanal Now I understand the problem ! Did you think any solution of this problem ?

@gaurab-khanal
Copy link
Copy Markdown
Contributor Author

@Rupam-It
Copy link
Copy Markdown
Contributor

Rupam-It commented Nov 4, 2025

I'm not sue about this !
I have to do research about it and if you done any research on this please go ahead!
check that if your proposed solution is working or not!

@rishi-jat
Copy link
Copy Markdown
Contributor

@gaurab-khanal is the issue you were facing is fixed ?

@gaurab-khanal
Copy link
Copy Markdown
Contributor Author

gaurab-khanal commented Nov 5, 2025

@Rupam-It here current context is returned instead of override context. https://github.com/kubestellar/kubectl-plugin/blob/main/pkg/cluster/discovery.go#L136

In test file, we have current context as test-context but here in this test case I have override the context to wds1 but the function is returning current context which is test-context.
So in this file at 1st check if context override is provided or not. If provided return ctxName as overridecontext else return current context.

@clubanderson clubanderson added the kind/test Categorizes issue or PR as related to testing. label Jan 13, 2026
@clubanderson
Copy link
Copy Markdown
Contributor

❌ PR Title Verification Failed

Your PR title does not follow the required format.

Current title: test: Add test cases for discovery.go

Required Format

PR titles must start with one of these emoji prefixes:

Emoji Meaning
⚠️ Breaking change
Non-breaking feature
🐛 Patch fix / Bug fix
📖 Documentation
🚀 Release
🌱 Infra/Tests/Other

How to Fix

Edit your PR title to start with the appropriate emoji. For example:

  • ✨ Add new feature for user authentication
  • 🐛 Fix crash when loading empty config
  • 📖 Update installation guide

You can edit the title by clicking the Edit button next to your PR title.


This comment was posted to help you fix the PR title format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/test Categorizes issue or PR as related to testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants