Skip to content

Commit

Permalink
Adding TestInstallation.AssertionsT (#10600)
Browse files Browse the repository at this point in the history
Co-authored-by: jmcguire98 <[email protected]>
  • Loading branch information
ryanrolds and jmcguire98 authored Feb 7, 2025
1 parent 4a5953a commit 2d3e0fc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/v1.19.0-beta6/tests-introducing-assertionst.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
- type: NON_USER_FACING
description: |
Introducing TestInstallation.AssertionsT method that provides a better
scoped assertions provider.
5 changes: 2 additions & 3 deletions test/kubernetes/e2e/features/server_tls/k8s_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ func (s *k8sServerTlsTestingSuite) TestOneWayServerTlsWorksWithOneWayTls() {
}

func (s *k8sServerTlsTestingSuite) assertEventualResponse(hostHeaderValue string, matcher *matchers.HttpResponse) {

// Check curl works against expected response
s.testInstallation.Assertions.AssertEventualCurlResponse(
s.testInstallation.AssertionsT(s.T()).AssertEventualCurlResponse(
s.ctx,
kubectl.PodExecOptions{
Name: "curl",
Expand All @@ -123,7 +122,7 @@ func (s *k8sServerTlsTestingSuite) assertEventualResponse(hostHeaderValue string

func (s *k8sServerTlsTestingSuite) assertEventualError(hostHeaderValue string, code int) {
// Check curl works against expected response
s.testInstallation.Assertions.AssertEventualCurlError(
s.testInstallation.AssertionsT(s.T()).AssertEventualCurlError(
s.ctx,
kubectl.PodExecOptions{
Name: "curl",
Expand Down
10 changes: 10 additions & 0 deletions test/kubernetes/e2e/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ func CreateTestInstallationForCluster(
WithClusterContext(clusterContext).
WithGlooGatewayContext(glooGatewayContext),

AssertionsT: func(t *testing.T) *assertions.Provider {
return assertions.NewProvider(t).
WithClusterContext(clusterContext).
WithGlooGatewayContext(glooGatewayContext)
},

// GeneratedFiles contains the unique location where files generated during the execution
// of tests against this installation will be stored
// By creating a unique location, per TestInstallation and per Cluster.Name we guarantee isolation
Expand Down Expand Up @@ -133,8 +139,12 @@ type TestInstallation struct {
Actions *actions.Provider

// Assertions is the entity that creates assertions that can be executed by the Operator
// DEPRECATED: Use AssertionsT instead (which is scoped to a specific test and not the root suite)
Assertions *assertions.Provider

// AssertionsT creates an assertion provider that is scoped to the provided test
AssertionsT func(*testing.T) *assertions.Provider

// GeneratedFiles is the collection of directories and files that this test installation _may_ create
GeneratedFiles GeneratedFiles

Expand Down

0 comments on commit 2d3e0fc

Please sign in to comment.