Skip to content

Commit

Permalink
test: add get cluster info test case (#21831)
Browse files Browse the repository at this point in the history
Signed-off-by: nitishfy <[email protected]>
  • Loading branch information
nitishfy authored Feb 11, 2025
1 parent d19b02d commit 9671268
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 0 additions & 3 deletions server/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ func TestCache_GetRepoConnectionState(t *testing.T) {
// populate cache
err = cache.SetRepoConnectionState("my-repo", "some-project", &ConnectionState{Status: "my-project-state"})
require.NoError(t, err)
// cache miss
_, err = cache.GetRepoConnectionState("other-repo", "")
assert.Equal(t, ErrCacheMiss, err)
// cache hit
value, err := cache.GetRepoConnectionState("my-repo", "")
require.NoError(t, err)
Expand Down
18 changes: 18 additions & 0 deletions util/cache/appstate/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ func TestCache_GetAppResourcesTree(t *testing.T) {
assert.Equal(t, &ApplicationTree{Nodes: []ResourceNode{{}}}, value)
}

func TestCache_GetClusterInfo(t *testing.T) {
cache := newFixtures().Cache
// cache miss
res := &ClusterInfo{}
err := cache.GetClusterInfo("http://minikube", res)
assert.Equal(t, ErrCacheMiss, err)
// populate cache
err = cache.SetClusterInfo("http://kind-cluster", &ClusterInfo{ServerVersion: "0.24.0"})
require.NoError(t, err)
// cache miss
err = cache.GetClusterInfo("http://kind-clusterss", res)
assert.Equal(t, ErrCacheMiss, err)
// cache hit
err = cache.GetClusterInfo("http://kind-cluster", res)
require.NoError(t, err)
assert.Equal(t, &ClusterInfo{ServerVersion: "0.24.0"}, res)
}

func TestAddCacheFlagsToCmd(t *testing.T) {
cache, err := AddCacheFlagsToCmd(&cobra.Command{})()
require.NoError(t, err)
Expand Down

0 comments on commit 9671268

Please sign in to comment.