Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
e83e799d
Commit
e83e799d
authored
Aug 22, 2017
by
zhangxiaoyu-zidif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix-review
parent
a7c69bd5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
21 deletions
+13
-21
BUILD
pkg/kubectl/cmd/util/BUILD
+1
-0
factory_test.go
pkg/kubectl/cmd/util/factory_test.go
+12
-21
No files found.
pkg/kubectl/cmd/util/BUILD
View file @
e83e799d
...
...
@@ -114,6 +114,7 @@ go_test(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/version:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
...
...
pkg/kubectl/cmd/util/factory_test.go
View file @
e83e799d
...
...
@@ -37,6 +37,7 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/apiserver/pkg/util/flag"
manualfake
"k8s.io/client-go/rest/fake"
...
...
@@ -88,22 +89,16 @@ func TestPortsForObject(t *testing.T) {
},
}
expected
:=
[]
string
{
"101"
}
got
,
err
:=
f
.
PortsForObject
(
pod
)
expected
:=
sets
.
NewString
(
"101"
)
ports
,
err
:=
f
.
PortsForObject
(
pod
)
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
if
len
(
expected
)
!=
len
(
got
)
{
t
.
Fatalf
(
"Ports size mismatch! Expected %d, got %d"
,
len
(
expected
),
len
(
got
))
}
sort
.
Strings
(
expected
)
sort
.
Strings
(
got
)
got
:=
sets
.
NewString
(
ports
...
)
for
i
,
port
:=
range
got
{
if
port
!=
expected
[
i
]
{
t
.
Fatalf
(
"Port mismatch! Expected %s, got %s"
,
expected
[
i
],
port
)
}
if
!
expected
.
Equal
(
got
)
{
t
.
Fatalf
(
"Ports mismatch! Expected %v, got %v"
,
expected
,
got
)
}
}
...
...
@@ -130,22 +125,18 @@ func TestProtocolsForObject(t *testing.T) {
},
}
expected
:=
"101/TCP,102/UDP"
expected
:=
sets
.
NewString
(
"101/TCP"
,
"102/UDP"
)
protocolsMap
,
err
:=
f
.
ProtocolsForObject
(
pod
)
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
got
:=
kubectl
.
MakeProtocols
(
protocolsMap
)
expectedSlice
:=
strings
.
Split
(
expected
,
","
)
gotSlice
:=
strings
.
Split
(
got
,
","
)
sort
.
Strings
(
expectedSlice
)
sort
.
Strings
(
gotSlice
)
protocolsString
:=
kubectl
.
MakeProtocols
(
protocolsMap
)
protocolsStrings
:=
strings
.
Split
(
protocolsString
,
","
)
got
:=
sets
.
NewString
(
protocolsStrings
...
)
for
i
,
protocol
:=
range
gotSlice
{
if
protocol
!=
expectedSlice
[
i
]
{
t
.
Fatalf
(
"Protocols mismatch! Expected %s, got %s"
,
expectedSlice
[
i
],
protocol
)
}
if
!
expected
.
Equal
(
got
)
{
t
.
Fatalf
(
"Protocols mismatch! Expected %v, got %v"
,
expected
,
got
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment