Created
May 16, 2023 17:10
-
-
Save eculver/af7dab271c779a05adee568c52d855b2 to your computer and use it in GitHub Desktop.
Example of updating to api test case with closure/func annotation for post-upgrade assertion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/api/agent_test.go b/api/agent_test.go | |
index ebf7381547..bfe27325c1 100644 | |
--- a/api/agent_test.go | |
+++ b/api/agent_test.go | |
@@ -1927,28 +1927,33 @@ func TestAgentService_Register_MeshGateway(t *testing.T) { | |
agent := c.Agent() | |
- reg := AgentServiceRegistration{ | |
- Kind: ServiceKindMeshGateway, | |
- Name: "mesh-gateway", | |
- Address: "10.1.2.3", | |
- Port: 8443, | |
- Proxy: &AgentServiceConnectProxyConfig{ | |
- Config: map[string]interface{}{ | |
- "foo": "bar", | |
+ // +upgrade-test-generator:assertion | |
+ doAssertion := func(c *Client, t *testing.T) { | |
+ reg := AgentServiceRegistration{ | |
+ Kind: ServiceKindMeshGateway, | |
+ Name: "mesh-gateway", | |
+ Address: "10.1.2.3", | |
+ Port: 8443, | |
+ Proxy: &AgentServiceConnectProxyConfig{ | |
+ Config: map[string]interface{}{ | |
+ "foo": "bar", | |
+ }, | |
}, | |
- }, | |
- } | |
+ } | |
- err := agent.ServiceRegister(®) | |
- require.NoError(t, err) | |
+ err := agent.ServiceRegister(®) | |
+ require.NoError(t, err) | |
- svc, _, err := agent.Service("mesh-gateway", nil) | |
- require.NoError(t, err) | |
- require.NotNil(t, svc) | |
- require.Equal(t, ServiceKindMeshGateway, svc.Kind) | |
- require.NotNil(t, svc.Proxy) | |
- require.Contains(t, svc.Proxy.Config, "foo") | |
- require.Equal(t, "bar", svc.Proxy.Config["foo"]) | |
+ svc, _, err := agent.Service("mesh-gateway", nil) | |
+ require.NoError(t, err) | |
+ require.NotNil(t, svc) | |
+ require.Equal(t, ServiceKindMeshGateway, svc.Kind) | |
+ require.NotNil(t, svc.Proxy) | |
+ require.Contains(t, svc.Proxy.Config, "foo") | |
+ require.Equal(t, "bar", svc.Proxy.Config["foo"]) | |
+ } | |
+ | |
+ doAssertion(c, t) | |
} | |
func TestAgentService_Register_TerminatingGateway(t *testing.T) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment