Skip to content

Commit

Permalink
Add tests for isNamespaceReferenced
Browse files Browse the repository at this point in the history
  • Loading branch information
bjee19 committed Dec 15, 2023
1 parent 335a517 commit 5159893
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions internal/mode/static/state/graph/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,46 @@ func TestBuildReferencedNamespaces(t *testing.T) {
})
}
}

func TestIsNamespaceReferenced(t *testing.T) {
tests := []struct {
ns *v1.Namespace
gw *Gateway
name string
exp bool
}{
{
ns: nil,
gw: nil,
exp: false,
name: "namespace and gateway are nil",
},
{
ns: &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "ns1",
},
},
gw: nil,
exp: false,
name: "namespace is valid but gateway is nil",
},
{
ns: nil,
gw: &Gateway{
Listeners: []*Listener{},
Valid: true,
},
exp: false,
name: "gateway is valid but namespace is nil",
},
}

// Other test cases should be covered by testing of BuildReferencedNamespaces
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
g := NewWithT(t)
g.Expect(isNamespaceReferenced(test.ns, test.gw)).To(Equal(test.exp))
})
}
}

0 comments on commit 5159893

Please sign in to comment.