Skip to content

Commit

Permalink
Merge pull request #1951 from yuannauy123/fanye-issue#1905
Browse files Browse the repository at this point in the history
test: add unit-test for apis/opts/portbindings.go
  • Loading branch information
allencloud authored Aug 10, 2018
2 parents 3d16d73 + 476d2fa commit 7a555f1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apis/opts/portbindings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ func TestParsePortBinding(t *testing.T) {
want types.PortMap
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
{name: "testCase1", args: args{ports: []string{"127.0.0.1:80:80"}}, want: map[string][]types.PortBinding{"80/tcp": {types.PortBinding{"127.0.0.1", "80"}}}, wantErr: false},
{name: "testCase2", args: args{ports: []string{"26:22"}}, want: map[string][]types.PortBinding{"22/tcp": {types.PortBinding{"", "26"}}}, wantErr: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -42,7 +44,11 @@ func TestVerifyPortBinding(t *testing.T) {
args args
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
{name: "testCase1", args: args{portBindings: map[string][]types.PortBinding{"21/ftp": {types.PortBinding{HostIP: "", HostPort: "21"}}}}, wantErr: false},
{name: "testCase2", args: args{portBindings: map[string][]types.PortBinding{"65537/tcp": {types.PortBinding{}}}}, wantErr: true},
{name: "testCase3", args: args{portBindings: map[string][]types.PortBinding{"0/tcp": {types.PortBinding{}}}}, wantErr: false},
{name: "testCase4", args: args{portBindings: map[string][]types.PortBinding{"80/http": {types.PortBinding{}}}}, wantErr: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 7a555f1

Please sign in to comment.