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
7a8e268c
Commit
7a8e268c
authored
Jul 23, 2014
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #548 from kelseyhightower/improve_kubecfg_tests
Use table testing for makePort tests
parents
44e40669
609050da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
kubecfg_test.go
pkg/kubecfg/kubecfg_test.go
+19
-13
No files found.
pkg/kubecfg/kubecfg_test.go
View file @
7a8e268c
...
...
@@ -20,6 +20,7 @@ import (
"encoding/json"
"io/ioutil"
"os"
"reflect"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
...
@@ -287,19 +288,24 @@ func TestLoadAuthInfo(t *testing.T) {
}
}
func
validatePort
(
t
*
testing
.
T
,
p
api
.
Port
,
external
int
,
internal
int
)
{
if
p
.
HostPort
!=
external
||
p
.
ContainerPort
!=
internal
{
t
.
Errorf
(
"Unexpected port: %#v != (%d, %d)"
,
p
,
external
,
internal
)
}
}
func
TestMakePorts
(
t
*
testing
.
T
)
{
ports
:=
makePorts
(
"8080:80,8081:8081,443:444"
)
if
len
(
ports
)
!=
3
{
t
.
Errorf
(
"Unexpected ports: %#v"
,
ports
)
var
makePortsTests
=
[]
struct
{
spec
string
ports
[]
api
.
Port
}{
{
"8080:80,8081:8081,443:444"
,
[]
api
.
Port
{
api
.
Port
{
HostPort
:
8080
,
ContainerPort
:
80
},
api
.
Port
{
HostPort
:
8081
,
ContainerPort
:
8081
},
api
.
Port
{
HostPort
:
443
,
ContainerPort
:
444
},
},
},
}
for
_
,
tt
:=
range
makePortsTests
{
ports
:=
makePorts
(
tt
.
spec
)
if
!
reflect
.
DeepEqual
(
ports
,
tt
.
ports
)
{
t
.
Errorf
(
"Expected %#v, got %#v"
,
tt
.
ports
,
ports
)
}
}
validatePort
(
t
,
ports
[
0
],
8080
,
80
)
validatePort
(
t
,
ports
[
1
],
8081
,
8081
)
validatePort
(
t
,
ports
[
2
],
443
,
444
)
}
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