Skip to content

Commit

Permalink
Fix portmap unit tests
Browse files Browse the repository at this point in the history
Use `conditionsV4` and `conditionsV6` values that actually look like
valid iptables conditions.

Signed-off-by: Dan Winship <[email protected]>
  • Loading branch information
danwinship authored and squeed committed Sep 16, 2024
1 parent a3ccebc commit 3d1968c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions plugins/meta/portmap/portmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ var _ = Describe("portmapping configuration", func() {
]
},
"snat": false,
"conditionsV4": ["a", "b"],
"conditionsV6": ["c", "d"],
"conditionsV4": ["-s", "1.2.3.4"],
"conditionsV6": ["-s", "12::34"],
"prevResult": {
"interfaces": [
{"name": "host"},
Expand Down Expand Up @@ -74,8 +74,8 @@ var _ = Describe("portmapping configuration", func() {
c, _, err := parseConfig(configBytes, "container")
Expect(err).NotTo(HaveOccurred())
Expect(c.CNIVersion).To(Equal(ver))
Expect(c.ConditionsV4).To(Equal(&[]string{"a", "b"}))
Expect(c.ConditionsV6).To(Equal(&[]string{"c", "d"}))
Expect(c.ConditionsV4).To(Equal(&[]string{"-s", "1.2.3.4"}))
Expect(c.ConditionsV6).To(Equal(&[]string{"-s", "12::34"}))
fvar := false
Expect(c.SNAT).To(Equal(&fvar))
Expect(c.Name).To(Equal("test"))
Expand All @@ -95,14 +95,14 @@ var _ = Describe("portmapping configuration", func() {
"type": "portmap",
"cniVersion": "%s",
"snat": false,
"conditionsV4": ["a", "b"],
"conditionsV6": ["c", "d"]
"conditionsV4": ["-s", "1.2.3.4"],
"conditionsV6": ["-s", "12::34"]
}`, ver))
c, _, err := parseConfig(configBytes, "container")
Expect(err).NotTo(HaveOccurred())
Expect(c.CNIVersion).To(Equal(ver))
Expect(c.ConditionsV4).To(Equal(&[]string{"a", "b"}))
Expect(c.ConditionsV6).To(Equal(&[]string{"c", "d"}))
Expect(c.ConditionsV4).To(Equal(&[]string{"-s", "1.2.3.4"}))
Expect(c.ConditionsV6).To(Equal(&[]string{"-s", "12::34"}))
fvar := false
Expect(c.SNAT).To(Equal(&fvar))
Expect(c.Name).To(Equal("test"))
Expand All @@ -114,8 +114,8 @@ var _ = Describe("portmapping configuration", func() {
"type": "portmap",
"cniVersion": "%s",
"snat": false,
"conditionsV4": ["a", "b"],
"conditionsV6": ["c", "d"],
"conditionsV4": ["-s", "1.2.3.4"],
"conditionsV6": ["-s", "12::34"],
"runtimeConfig": {
"portMappings": [
{ "hostPort": 0, "containerPort": 80, "protocol": "tcp"}
Expand All @@ -136,7 +136,7 @@ var _ = Describe("portmapping configuration", func() {
{ "hostPort": 8080, "containerPort": 80, "protocol": "tcp"}
]
},
"conditionsV4": ["a", "b"],
"conditionsV4": ["-s", "1.2.3.4"],
"prevResult": {
"interfaces": [
{"name": "host"}
Expand Down

0 comments on commit 3d1968c

Please sign in to comment.