Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jcscottiii committed Aug 10, 2023
1 parent ed80df7 commit 66aae6a
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions pkg/skaffold/deploy/docker/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,65 @@ func TestDebugBindings(t *testing.T) {
}
}

func TestFilterPortForwardingResources(t *testing.T) {
resources := []*latest.PortForwardResource{
{
Name: "image1",
Port: util.FromInt(8000),
},
{
Name: "image2",
Port: util.FromInt(8001),
},
{
Name: "image2",
Port: util.FromInt(8002),
},
}
tests := []struct {
name string
imageName string
expectedPortResources []*latest.PortForwardResource
}{
{
name: "image name not in list",
imageName: "image3",
expectedPortResources: []*latest.PortForwardResource{},
},
{
name: "image in list. return one",
imageName: "image1",
expectedPortResources: []*latest.PortForwardResource{
{
Name: "image1",
Port: util.FromInt(8000),
},
},
},
{
name: "image in list. return multiple",
imageName: "image2",
expectedPortResources: []*latest.PortForwardResource{
{
Name: "image2",
Port: util.FromInt(8001),
},
{
Name: "image2",
Port: util.FromInt(8002),
},
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
d := Deployer{resources: resources}
pfResources := d.filterPortForwardingResources(test.imageName)
testutil.CheckDeepEqual(t, test.expectedPortResources, pfResources)
})
}
}

type mockConfig struct{}

func (m mockConfig) ContainerDebugging() bool { return true }
Expand Down

0 comments on commit 66aae6a

Please sign in to comment.