Skip to content

Commit

Permalink
Add graph test
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-osborn committed Jun 28, 2023
1 parent 0db9b17 commit f869c1a
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions internal/state/graph/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ func TestBuildGraph(t *testing.T) {
Mode: helpers.GetTLSModePointer(v1beta1.TLSModeTerminate),
CertificateRefs: []v1beta1.SecretObjectReference{
{
Kind: (*v1beta1.Kind)(helpers.GetStringPointer("Secret")),
Kind: helpers.GetPointer[v1beta1.Kind]("Secret"),
Name: "secret",
Namespace: (*v1beta1.Namespace)(helpers.GetStringPointer("test")),
Namespace: helpers.GetPointer[v1beta1.Namespace]("certificate"),
},
},
},
Expand All @@ -145,6 +145,27 @@ func TestBuildGraph(t *testing.T) {

svc := &v1.Service{ObjectMeta: metav1.ObjectMeta{Namespace: "test", Name: "foo"}}

rg := &v1beta1.ReferenceGrant{
ObjectMeta: metav1.ObjectMeta{
Name: "rg",
Namespace: "certificate",
},
Spec: v1beta1.ReferenceGrantSpec{
From: []v1beta1.ReferenceGrantFrom{
{
Group: v1beta1.GroupName,
Kind: "Gateway",
Namespace: "test",
},
},
To: []v1beta1.ReferenceGrantTo{
{
Kind: "Secret",
},
},
},
}

createStateWithGatewayClass := func(gc *v1beta1.GatewayClass) ClusterState {
return ClusterState{
GatewayClasses: map[types.NamespacedName]*v1beta1.GatewayClass{
Expand All @@ -162,6 +183,9 @@ func TestBuildGraph(t *testing.T) {
Services: map[types.NamespacedName]*v1.Service{
client.ObjectKeyFromObject(svc): svc,
},
ReferenceGrants: map[types.NamespacedName]*v1beta1.ReferenceGrant{
client.ObjectKeyFromObject(rg): rg,
},
}
}

Expand Down Expand Up @@ -199,7 +223,7 @@ func TestBuildGraph(t *testing.T) {

secretMemoryMgr := &secretsfakes.FakeSecretDiskMemoryManager{}
secretMemoryMgr.RequestCalls(func(nsname types.NamespacedName) (string, error) {
if (nsname == types.NamespacedName{Namespace: "test", Name: "secret"}) {
if (nsname == types.NamespacedName{Namespace: "certificate", Name: "secret"}) {
return secretPath, nil
}
panic("unexpected secret request")
Expand Down

0 comments on commit f869c1a

Please sign in to comment.