-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dashboard to status command. Fail gracefully on error. (#473)
- Loading branch information
1 parent
f00cb05
commit 0703152
Showing
5 changed files
with
320 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// ------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
// ------------------------------------------------------------ | ||
|
||
package kubernetes | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes/fake" | ||
) | ||
|
||
func TestListPodsInterface(t *testing.T) { | ||
t.Run("empty list pods", func(t *testing.T) { | ||
k8s := fake.NewSimpleClientset() | ||
output, err := ListPodsInterface(k8s, map[string]string{ | ||
"test": "test", | ||
}) | ||
assert.Nil(t, err, "unexpected error") | ||
assert.NotNil(t, output, "Expected empty list") | ||
assert.Equal(t, 0, len(output.Items), "Expected length 0") | ||
}) | ||
t.Run("one matching pod", func(t *testing.T) { | ||
k8s := fake.NewSimpleClientset((&v1.Pod{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "test", | ||
Namespace: "test", | ||
Annotations: map[string]string{}, | ||
Labels: map[string]string{ | ||
"test": "test", | ||
}, | ||
}, | ||
})) | ||
output, err := ListPodsInterface(k8s, map[string]string{ | ||
"test": "test", | ||
}) | ||
assert.Nil(t, err, "unexpected error") | ||
assert.NotNil(t, output, "Expected non empty list") | ||
assert.Equal(t, 1, len(output.Items), "Expected length 0") | ||
assert.Equal(t, "test", output.Items[0].Name, "expected name to match") | ||
assert.Equal(t, "test", output.Items[0].Namespace, "expected namespace to match") | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.