Merge pull request #52765 from lichen2013/chenli

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Using assertions in Unit tests

Using assertions:

1. cmd/kube-controller-manager/app/controller_manager_test.go
2. pkg/controller/bootstrap/jws_test.go
3. pkg/controller/cloud/node_controller_test.go
4. pkg/controller/controller_utils_test.go

Partially fix https://github.com/kubernetes/kubernetes/issues/43788
This commit is contained in:
Kubernetes Submit Queue
2017-10-11 07:42:45 -07:00
committed by GitHub
7 changed files with 166 additions and 221 deletions

View File

@@ -151,5 +151,8 @@ go_test(
name = "go_default_test",
srcs = ["controller_manager_test.go"],
library = ":go_default_library",
deps = ["//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library"],
deps = [
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
],
)

View File

@@ -24,6 +24,8 @@ import (
"testing"
"k8s.io/apimachinery/pkg/util/sets"
"github.com/stretchr/testify/assert"
)
func TestIsControllerEnabled(t *testing.T) {
@@ -73,9 +75,7 @@ func TestIsControllerEnabled(t *testing.T) {
for _, tc := range tcs {
actual := IsControllerEnabled(tc.controllerName, sets.NewString(tc.disabledByDefaultControllers...), tc.controllers...)
if actual != tc.expected {
t.Errorf("%v: expected %v, got %v", tc.name, tc.expected, actual)
}
assert.Equal(t, tc.expected, actual, "%v: expected %v, got %v", tc.name, tc.expected, actual)
}
}