Merge pull request #13 from digitalocean/varsha/add-tests
Add tests around metadata for each checkvarsha/versions
commit
e91923530c
|
@ -11,14 +11,14 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func TestMeta(t *testing.T) {
|
||||
func TestLatestTagCheckMeta(t *testing.T) {
|
||||
latestTagCheck := latestTagCheck{}
|
||||
assert.Equal(t, "latest-tag", latestTagCheck.Name())
|
||||
assert.Equal(t, "Checks if there are pods with container images having latest tag", latestTagCheck.Description())
|
||||
assert.Equal(t, []string{"basic"}, latestTagCheck.Groups())
|
||||
}
|
||||
|
||||
func TestRegistration(t *testing.T) {
|
||||
func TestLatestTagCheckRegistration(t *testing.T) {
|
||||
latestTagCheck := &latestTagCheck{}
|
||||
check, err := checks.Get("latest-tag")
|
||||
assert.Equal(t, check, latestTagCheck)
|
||||
|
|
|
@ -4,12 +4,27 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/digitalocean/clusterlint/checks"
|
||||
"github.com/digitalocean/clusterlint/kube"
|
||||
"github.com/stretchr/testify/assert"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func TestNamespaceCheckMeta(t *testing.T) {
|
||||
defaultNamespaceCheck := defaultNamespaceCheck{}
|
||||
assert.Equal(t, "default-namespace", defaultNamespaceCheck.Name())
|
||||
assert.Equal(t, "Checks if there are any user created k8s objects in the default namespace.", defaultNamespaceCheck.Description())
|
||||
assert.Equal(t, []string{"basic"}, defaultNamespaceCheck.Groups())
|
||||
}
|
||||
|
||||
func TestNamespaceCheckRegistration(t *testing.T) {
|
||||
defaultNamespaceCheck := &defaultNamespaceCheck{}
|
||||
check, err := checks.Get("default-namespace")
|
||||
assert.Equal(t, check, defaultNamespaceCheck)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestNamespaceWarning(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
name string
|
||||
|
|
|
@ -4,17 +4,27 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/digitalocean/clusterlint/checks"
|
||||
"github.com/digitalocean/clusterlint/kube"
|
||||
"github.com/stretchr/testify/assert"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func TestGroup(t *testing.T) {
|
||||
func TestPodSelectorCheckMeta(t *testing.T) {
|
||||
podSelectorCheck := podSelectorCheck{}
|
||||
assert.Equal(t, "node-name-pod-selector", podSelectorCheck.Name())
|
||||
assert.Equal(t, "Checks if there are pods which use kubernetes.io/hostname label in the node selector.", podSelectorCheck.Description())
|
||||
assert.Equal(t, []string{"doks"}, podSelectorCheck.Groups())
|
||||
}
|
||||
|
||||
func TestPodSelectorCheckRegistration(t *testing.T) {
|
||||
podSelectorCheck := &podSelectorCheck{}
|
||||
check, err := checks.Get("node-name-pod-selector")
|
||||
assert.Equal(t, check, podSelectorCheck)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestNodeNameError(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
name string
|
||||
|
|
Loading…
Reference in New Issue