Skip to content
Permalink
Browse files

Add a test for fake metrics.k8s.io Clientset.

This test demonstrates the fix in
#75486.
  • Loading branch information...
misterikkit committed Mar 20, 2019
1 parent 40e1f0f commit fcb593e036e7f7815b08b7dd0dbc1eeb38b549e9
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
@@ -37,3 +37,13 @@ filegroup(
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

go_test(
name = "go_default_test",
srcs = ["clientset_test.go"],
embed = [":go_default_library"],
deps = [
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/metrics/pkg/client/clientset/versioned/fake:go_default_library",
],
)
@@ -0,0 +1,25 @@
package versioned_test

import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/metrics/pkg/client/clientset/versioned/fake"
)

// TestList is a basic sanity check that makes sure the fake Clientset is working properly.
func TestList(t *testing.T) {
client := fake.NewSimpleClientset()
if _, err := client.MetricsV1alpha1().PodMetricses("").List(metav1.ListOptions{}); err != nil {
t.Errorf("Unexpected error: %v", err)
}
if _, err := client.MetricsV1alpha1().NodeMetricses().List(metav1.ListOptions{}); err != nil {
t.Errorf("Unexpected error: %v", err)
}
if _, err := client.MetricsV1beta1().PodMetricses("").List(metav1.ListOptions{}); err != nil {
t.Errorf("Unexpected error: %v", err)
}
if _, err := client.MetricsV1beta1().NodeMetricses().List(metav1.ListOptions{}); err != nil {
t.Errorf("Unexpected error: %v", err)
}
}

0 comments on commit fcb593e

Please sign in to comment.
You can’t perform that action at this time.