Skip to content

Commit

Permalink
Merge pull request #38841 from mikedanese/fix-tests
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

bazel: fix some unit tests
  • Loading branch information
Kubernetes Submit Queue committed Dec 16, 2016
2 parents 5ec2fb0 + 8fdec87 commit e2a9fc1
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 12 deletions.
6 changes: 5 additions & 1 deletion cmd/kubeadm/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ go_test(
name = "go_default_test",
srcs = ["token_test.go"],
library = "go_default_library",
tags = ["automanaged"],
tags = [
"automanaged",
"integration",
"skip",
],
deps = [],
)
6 changes: 6 additions & 0 deletions pkg/client/testdata/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package(default_visibility = ["//visibility:public"])

filegroup(
name = "testdata",
srcs = glob(["*"]),
)
1 change: 0 additions & 1 deletion pkg/kubectl/cmd/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ go_test(
library = "go_default_library",
tags = [
"automanaged",
"skip",
],
deps = [
"//pkg/api:go_default_library",
Expand Down
1 change: 0 additions & 1 deletion pkg/kubectl/resource/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ go_test(
library = "go_default_library",
tags = [
"automanaged",
"skip",
],
deps = [
"//pkg/api:go_default_library",
Expand Down
6 changes: 4 additions & 2 deletions pkg/kubectl/resource/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
Expand Down Expand Up @@ -1179,6 +1180,7 @@ func TestReceiveMultipleErrors(t *testing.T) {
}

func TestHasNames(t *testing.T) {
basename := filepath.Base(os.Args[0])
tests := []struct {
args []string
expectedHasName bool
Expand Down Expand Up @@ -1222,13 +1224,13 @@ func TestHasNames(t *testing.T) {
{
args: []string{"rc/foo", "bar"},
expectedHasName: false,
expectedError: fmt.Errorf("there is no need to specify a resource type as a separate argument when passing arguments in resource/name form (e.g. 'resource.test get resource/<resource_name>' instead of 'resource.test get resource resource/<resource_name>'"),
expectedError: fmt.Errorf("there is no need to specify a resource type as a separate argument when passing arguments in resource/name form (e.g. '" + basename + " get resource/<resource_name>' instead of '" + basename + " get resource resource/<resource_name>'"),
},
}
for _, test := range tests {
hasNames, err := HasNames(test.args)
if !reflect.DeepEqual(test.expectedError, err) {
t.Errorf("expected HasName to error %v, got %s", test.expectedError, err)
t.Errorf("expected HasName to error:\n%s\tgot:\n%s", test.expectedError, err)
}
if hasNames != test.expectedHasName {
t.Errorf("expected HasName to return %v for %s", test.expectedHasName, test.args)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["kubelet_client_test.go"],
data = ["//pkg/client/testdata"],
library = "go_default_library",
tags = [
"automanaged",
"skip",
],
deps = [
"//pkg/client/clientset_generated/clientset/typed/core/v1:go_default_library",
Expand Down
1 change: 0 additions & 1 deletion pkg/kubelet/dockertools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ go_test(
library = "go_default_library",
tags = [
"automanaged",
"skip",
],
deps = [
"//pkg/api:go_default_library",
Expand Down
4 changes: 1 addition & 3 deletions pkg/kubelet/dockertools/docker_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"path"
"reflect"
"regexp"
goruntime "runtime"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -1896,8 +1895,7 @@ func TestSeccompLocalhostProfileIsLoaded(t *testing.T) {
recorder := record.NewFakeRecorder(20)
dm.recorder = recorder

_, filename, _, _ := goruntime.Caller(0)
dm.seccompProfileRoot = path.Join(path.Dir(filename), "fixtures", "seccomp")
dm.seccompProfileRoot = path.Join("fixtures", "seccomp")

pod := makePod("foo2", &v1.PodSpec{
Containers: []v1.Container{
Expand Down
4 changes: 3 additions & 1 deletion pkg/util/procfs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["procfs_linux_test.go"],
data = [
"example_proc_cgroup",
],
library = "go_default_library",
tags = [
"automanaged",
"skip",
],
deps = ["//vendor:github.com/stretchr/testify/assert"],
)
3 changes: 3 additions & 0 deletions plugin/pkg/auth/authorizer/rbac/bootstrappolicy/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ go_library(
go_test(
name = "go_default_xtest",
srcs = ["policy_test.go"],
data = glob([
"testdata/*",
]),
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
Expand Down
1 change: 0 additions & 1 deletion plugin/pkg/scheduler/algorithmprovider/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ go_test(
library = "go_default_library",
tags = [
"automanaged",
"skip",
],
deps = ["//plugin/pkg/scheduler/factory:go_default_library"],
)

0 comments on commit e2a9fc1

Please sign in to comment.