Skip to content

Commit 2d3e0fc

Browse files
Adding TestInstallation.AssertionsT (#10600)
Co-authored-by: jmcguire98 <[email protected]>
1 parent 4a5953a commit 2d3e0fc

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
changelog:
2+
- type: NON_USER_FACING
3+
description: |
4+
Introducing TestInstallation.AssertionsT method that provides a better
5+
scoped assertions provider.

test/kubernetes/e2e/features/server_tls/k8s_suite.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ func (s *k8sServerTlsTestingSuite) TestOneWayServerTlsWorksWithOneWayTls() {
108108
}
109109

110110
func (s *k8sServerTlsTestingSuite) assertEventualResponse(hostHeaderValue string, matcher *matchers.HttpResponse) {
111-
112111
// Check curl works against expected response
113-
s.testInstallation.Assertions.AssertEventualCurlResponse(
112+
s.testInstallation.AssertionsT(s.T()).AssertEventualCurlResponse(
114113
s.ctx,
115114
kubectl.PodExecOptions{
116115
Name: "curl",
@@ -123,7 +122,7 @@ func (s *k8sServerTlsTestingSuite) assertEventualResponse(hostHeaderValue string
123122

124123
func (s *k8sServerTlsTestingSuite) assertEventualError(hostHeaderValue string, code int) {
125124
// Check curl works against expected response
126-
s.testInstallation.Assertions.AssertEventualCurlError(
125+
s.testInstallation.AssertionsT(s.T()).AssertEventualCurlError(
127126
s.ctx,
128127
kubectl.PodExecOptions{
129128
Name: "curl",

test/kubernetes/e2e/test.go

+10
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ func CreateTestInstallationForCluster(
102102
WithClusterContext(clusterContext).
103103
WithGlooGatewayContext(glooGatewayContext),
104104

105+
AssertionsT: func(t *testing.T) *assertions.Provider {
106+
return assertions.NewProvider(t).
107+
WithClusterContext(clusterContext).
108+
WithGlooGatewayContext(glooGatewayContext)
109+
},
110+
105111
// GeneratedFiles contains the unique location where files generated during the execution
106112
// of tests against this installation will be stored
107113
// By creating a unique location, per TestInstallation and per Cluster.Name we guarantee isolation
@@ -133,8 +139,12 @@ type TestInstallation struct {
133139
Actions *actions.Provider
134140

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

145+
// AssertionsT creates an assertion provider that is scoped to the provided test
146+
AssertionsT func(*testing.T) *assertions.Provider
147+
138148
// GeneratedFiles is the collection of directories and files that this test installation _may_ create
139149
GeneratedFiles GeneratedFiles
140150

0 commit comments

Comments
 (0)