Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Date Huang <[email protected]>
  • Loading branch information
tjjh89017 committed Apr 19, 2023
1 parent 398dc48 commit 5524302
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions plugins/main/bridge/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1764,27 +1764,23 @@ var _ = Describe("bridge Operations", func() {
Expect(testutils.UnmountNS(targetNS)).To(Succeed())
})

DescribeTable(
"collectVlanTrunk succeeds",
func(vlanTrunks ...*VlanTrunk, expectedVIDs []int) {
Expect(collectVlanTrunk(vlanTrunks)).To(Equal(expectedVIDs))
},
Entry("", &VlanTrunk{}, []int{}),
Entry("", &VlanTrunk{minID: 100, maxID: 105}, []int{100, 101, 102, 103, 104, 105}),
Entry("", &VlanTrunk{minID: 100, maxID: 105}, &VlanTrunk{id: 200}, []int{100, 101, 102, 103, 104, 105, 200}),
var (
correctMinID int = 100
correctMaxID int = 105
)

DescribeTable(
"collectVlanTrunk **fails**",
func(vlanTrunks ...*vlanTrunk, expectedError error) {
Expect(collectVlanTrunk(vlanTrunks)).To(MatchError(expectedError))
"collectVlanTrunk succeeds",
func(vlanTrunks []*VlanTrunk, expectedVIDs []int) {
Expect(collectVlanTrunk(vlanTrunks)).To(Equal(expectedVIDs))
},
Entry("", &VlanTrunk{minID: 100}, fmt.Errorf("minID and maxID should be configured simultaneously, maxID is missing")),
Entry("", &VlanTrunk{maxID: 100}, fmt.Errorf("minID and maxID should be configured simultaneously, minID is missing")),
Entry("", &VlanTrunk{minID: -100, maxID: 105}, fmt.Errorf("incorrect trunk minID parameter")),
Entry("", &VlanTrunk{minID: 10000, maxID: 105}, fmt.Errorf("incorrect trunk minID parameter")),
Entry("", &VlanTrunk{minID: 100, maxID: 10000}, fmt.Errorf("incorrect trunk minID parameter")),
Entry("", &VlanTrunk{minID: 100, maxID: -1}, fmt.Errorf("incorrect trunk minID parameter")),
Entry("", &[]*VlanTrunk{}, []int{}),
Entry("", &[]*VlanTrunk{
&VlanTrunk{
minID: &correctMinID,
maxID: &correctMaxID,
},
}, []int{100, 101, 102, 103, 104, 105}),
)

for _, ver := range testutils.AllSpecVersions {
Expand Down

0 comments on commit 5524302

Please sign in to comment.