test: check for httproute clean-up

Signed-off-by: Miguel Varela Ramos <miguel@cohere.ai>
This commit is contained in:
Miguel Varela Ramos 2024-07-17 11:39:51 +01:00
parent dc100b4cfc
commit 767725861a
No known key found for this signature in database
GPG Key ID: A6E2B8DFE1668FFD

View File

@ -99,6 +99,43 @@ func TestGetGatewayHTTPRouteForChallenge(t *testing.T) {
}
},
},
"should clean-up if there are multiple httproute resources": {
Challenge: &cmacme.Challenge{
Spec: cmacme.ChallengeSpec{
DNSName: "example.com",
Solver: cmacme.ACMEChallengeSolver{
HTTP01: &cmacme.ACMEChallengeSolverHTTP01{
GatewayHTTPRoute: &cmacme.ACMEChallengeSolverHTTP01GatewayHTTPRoute{},
},
},
},
},
Err: true,
PreFn: func(t *testing.T, s *solverFixture) {
_, err := s.Solver.createGatewayHTTPRoute(context.TODO(), s.Challenge, "fakeservice")
if err != nil {
t.Errorf("error preparing test: %v", err)
}
_, err = s.Solver.createGatewayHTTPRoute(context.TODO(), s.Challenge, "fakeservice")
if err != nil {
t.Errorf("error preparing test: %v", err)
}
s.Builder.Sync()
},
CheckFn: func(t *testing.T, s *solverFixture, args ...interface{}) {
httpRoutes, err := s.Solver.httpRouteLister.List(labels.NewSelector())
if err != nil {
t.Errorf("error listing HTTPRoutes: %v", err)
t.Fail()
return
}
if len(httpRoutes) != 1 {
t.Errorf("Expected 1 HTTPRoute, but got: %v", len(httpRoutes))
}
},
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {