Update go dependencies
This commit is contained in:
parent
15ffb51394
commit
bb4d483837
1621 changed files with 86368 additions and 284392 deletions
35
vendor/k8s.io/kubernetes/pkg/kubelet/util/format/resources_test.go
generated
vendored
35
vendor/k8s.io/kubernetes/pkg/kubelet/util/format/resources_test.go
generated
vendored
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package format
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
)
|
||||
|
||||
func TestResourceList(t *testing.T) {
|
||||
resourceList := v1.ResourceList{}
|
||||
resourceList[v1.ResourceCPU] = resource.MustParse("100m")
|
||||
resourceList[v1.ResourceMemory] = resource.MustParse("5Gi")
|
||||
actual := ResourceList(resourceList)
|
||||
expected := "cpu=100m,memory=5Gi"
|
||||
if actual != expected {
|
||||
t.Errorf("Unexpected result, actual: %v, expected: %v", actual, expected)
|
||||
}
|
||||
}
|
||||
222
vendor/k8s.io/kubernetes/pkg/kubelet/util/sliceutils/sliceutils_test.go
generated
vendored
222
vendor/k8s.io/kubernetes/pkg/kubelet/util/sliceutils/sliceutils_test.go
generated
vendored
|
|
@ -1,222 +0,0 @@
|
|||
/*
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package sliceutils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestStringInSlice(t *testing.T) {
|
||||
fooTests := []struct {
|
||||
s string
|
||||
list []string
|
||||
er bool
|
||||
}{
|
||||
{"first", []string{"first", "second"}, true},
|
||||
{"FIRST", []string{"first", "second"}, false},
|
||||
{"third", []string{"first", "second"}, false},
|
||||
{"first", nil, false},
|
||||
|
||||
{"", []string{"first", "second"}, false},
|
||||
{"", []string{"first", "second", ""}, true},
|
||||
{"", nil, false},
|
||||
}
|
||||
|
||||
for _, fooTest := range fooTests {
|
||||
r := StringInSlice(fooTest.s, fooTest.list)
|
||||
if r != fooTest.er {
|
||||
t.Errorf("returned %t but expected %t for s=%s & list=%s", r, fooTest.er, fooTest.s, fooTest.list)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func buildPodsByCreationTime() PodsByCreationTime {
|
||||
return []*v1.Pod{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo1",
|
||||
Namespace: v1.NamespaceDefault,
|
||||
CreationTimestamp: metav1.Time{
|
||||
Time: time.Now(),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo2",
|
||||
Namespace: v1.NamespaceDefault,
|
||||
CreationTimestamp: metav1.Time{
|
||||
Time: time.Now().Add(time.Hour * 1),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo3",
|
||||
Namespace: v1.NamespaceDefault,
|
||||
CreationTimestamp: metav1.Time{
|
||||
Time: time.Now().Add(time.Hour * 2),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestPodsByCreationTimeLen(t *testing.T) {
|
||||
fooTests := []struct {
|
||||
pods PodsByCreationTime
|
||||
el int
|
||||
}{
|
||||
{[]*v1.Pod{}, 0},
|
||||
{buildPodsByCreationTime(), 3},
|
||||
{[]*v1.Pod{nil, {}}, 2},
|
||||
{nil, 0},
|
||||
}
|
||||
|
||||
for _, fooTest := range fooTests {
|
||||
r := fooTest.pods.Len()
|
||||
if r != fooTest.el {
|
||||
t.Errorf("returned %d but expected %d for the len of PodsByCreationTime=%s", r, fooTest.el, fooTest.pods)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPodsByCreationTimeSwap(t *testing.T) {
|
||||
fooTests := []struct {
|
||||
pods PodsByCreationTime
|
||||
i int
|
||||
j int
|
||||
}{
|
||||
{buildPodsByCreationTime(), 0, 1},
|
||||
{buildPodsByCreationTime(), 2, 1},
|
||||
}
|
||||
|
||||
for _, fooTest := range fooTests {
|
||||
fooi := fooTest.pods[fooTest.i]
|
||||
fooj := fooTest.pods[fooTest.j]
|
||||
fooTest.pods.Swap(fooTest.i, fooTest.j)
|
||||
if fooi.GetName() != fooTest.pods[fooTest.j].GetName() || fooj.GetName() != fooTest.pods[fooTest.i].GetName() {
|
||||
t.Errorf("failed to swap for %v", fooTest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPodsByCreationTimeLess(t *testing.T) {
|
||||
fooTests := []struct {
|
||||
pods PodsByCreationTime
|
||||
i int
|
||||
j int
|
||||
er bool
|
||||
}{
|
||||
// ascending order
|
||||
{buildPodsByCreationTime(), 0, 2, true},
|
||||
{buildPodsByCreationTime(), 1, 0, false},
|
||||
}
|
||||
|
||||
for _, fooTest := range fooTests {
|
||||
r := fooTest.pods.Less(fooTest.i, fooTest.j)
|
||||
if r != fooTest.er {
|
||||
t.Errorf("returned %t but expected %t for the foo=%s", r, fooTest.er, fooTest.pods)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func buildByImageSize() ByImageSize {
|
||||
return []kubecontainer.Image{
|
||||
{
|
||||
ID: "1",
|
||||
RepoTags: []string{"foo-tag11", "foo-tag12"},
|
||||
RepoDigests: []string{"foo-rd11", "foo-rd12"},
|
||||
Size: 1,
|
||||
},
|
||||
{
|
||||
ID: "2",
|
||||
RepoTags: []string{"foo-tag21", "foo-tag22"},
|
||||
RepoDigests: []string{"foo-rd21", "foo-rd22"},
|
||||
Size: 2,
|
||||
},
|
||||
{
|
||||
ID: "3",
|
||||
RepoTags: []string{"foo-tag31", "foo-tag32"},
|
||||
RepoDigests: []string{"foo-rd31", "foo-rd32"},
|
||||
Size: 3,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestByImageSizeLen(t *testing.T) {
|
||||
fooTests := []struct {
|
||||
images ByImageSize
|
||||
el int
|
||||
}{
|
||||
{[]kubecontainer.Image{}, 0},
|
||||
{buildByImageSize(), 3},
|
||||
{nil, 0},
|
||||
}
|
||||
|
||||
for _, fooTest := range fooTests {
|
||||
r := fooTest.images.Len()
|
||||
if r != fooTest.el {
|
||||
t.Errorf("returned %d but expected %d for the len of ByImageSize=%v", r, fooTest.el, fooTest.images)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestByImageSizeSwap(t *testing.T) {
|
||||
fooTests := []struct {
|
||||
images ByImageSize
|
||||
i int
|
||||
j int
|
||||
}{
|
||||
{buildByImageSize(), 0, 1},
|
||||
{buildByImageSize(), 2, 1},
|
||||
}
|
||||
|
||||
for _, fooTest := range fooTests {
|
||||
fooi := fooTest.images[fooTest.i]
|
||||
fooj := fooTest.images[fooTest.j]
|
||||
fooTest.images.Swap(fooTest.i, fooTest.j)
|
||||
if fooi.ID != fooTest.images[fooTest.j].ID || fooj.ID != fooTest.images[fooTest.i].ID {
|
||||
t.Errorf("failed to swap for %v", fooTest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestByImageSizeLess(t *testing.T) {
|
||||
fooTests := []struct {
|
||||
images ByImageSize
|
||||
i int
|
||||
j int
|
||||
er bool
|
||||
}{
|
||||
// descending order
|
||||
{buildByImageSize(), 0, 2, false},
|
||||
{buildByImageSize(), 1, 0, true},
|
||||
}
|
||||
|
||||
for _, fooTest := range fooTests {
|
||||
r := fooTest.images.Less(fooTest.i, fooTest.j)
|
||||
if r != fooTest.er {
|
||||
t.Errorf("returned %t but expected %t for the foo=%v", r, fooTest.er, fooTest.images)
|
||||
}
|
||||
}
|
||||
}
|
||||
64
vendor/k8s.io/kubernetes/pkg/kubelet/util/util_test.go
generated
vendored
64
vendor/k8s.io/kubernetes/pkg/kubelet/util/util_test.go
generated
vendored
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestParseEndpoint(t *testing.T) {
|
||||
tests := []struct {
|
||||
endpoint string
|
||||
expectError bool
|
||||
expectedProtocol string
|
||||
expectedAddr string
|
||||
}{
|
||||
{
|
||||
endpoint: "unix:///tmp/s1.sock",
|
||||
expectedProtocol: "unix",
|
||||
expectedAddr: "/tmp/s1.sock",
|
||||
},
|
||||
{
|
||||
endpoint: "tcp://localhost:15880",
|
||||
expectedProtocol: "tcp",
|
||||
expectedAddr: "localhost:15880",
|
||||
},
|
||||
{
|
||||
endpoint: "tcp1://abc",
|
||||
expectedProtocol: "tcp1",
|
||||
expectError: true,
|
||||
},
|
||||
{
|
||||
endpoint: "a b c",
|
||||
expectError: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
protocol, addr, err := parseEndpoint(test.endpoint)
|
||||
assert.Equal(t, test.expectedProtocol, protocol)
|
||||
if test.expectError {
|
||||
assert.NotNil(t, err, "Expect error during parsing %q", test.endpoint)
|
||||
continue
|
||||
}
|
||||
assert.Nil(t, err, "Expect no error during parsing %q", test.endpoint)
|
||||
assert.Equal(t, test.expectedAddr, addr)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue