test: rename ExpectMatchContext to ExpectMatch (#25998)

Cleans the last few instances of ExpectMatch that didn't use the new `(ctx, ...)` variant, then deletes the deprecated method and renames `ExpectMatchContext` to drop the `Context` suffix.
This commit is contained in:
Spike Curtis
2026-06-03 15:30:37 -04:00
committed by GitHub
parent 7d7cc27581
commit 5b692bf1cc
66 changed files with 524 additions and 536 deletions
+4 -4
View File
@@ -450,9 +450,9 @@ func TestEnterpriseCreateWithPreset(t *testing.T) {
// Should: display the selected preset as well as its parameters
presetName := fmt.Sprintf("Preset '%s' applied:", preset.Name)
stdout.ExpectMatchContext(ctx, presetName)
stdout.ExpectMatchContext(ctx, fmt.Sprintf("%s: '%s'", firstParameterName, secondOptionalParameterValue))
stdout.ExpectMatchContext(ctx, fmt.Sprintf("%s: '%s'", thirdParameterName, thirdParameterValue))
stdout.ExpectMatch(ctx, presetName)
stdout.ExpectMatch(ctx, fmt.Sprintf("%s: '%s'", firstParameterName, secondOptionalParameterValue))
stdout.ExpectMatch(ctx, fmt.Sprintf("%s: '%s'", thirdParameterName, thirdParameterValue))
// Verify if the new workspace uses expected parameters.
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
@@ -561,7 +561,7 @@ func TestEnterpriseCreateWithPreset(t *testing.T) {
stdout := expecter.NewAttachedToInvocation(t, inv)
err = inv.Run()
require.NoError(t, err)
stdout.ExpectMatchContext(ctx, "No preset applied.")
stdout.ExpectMatch(ctx, "No preset applied.")
// Verify if the new workspace uses expected parameters.
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
+15 -15
View File
@@ -117,14 +117,14 @@ func TestExternalWorkspaces(t *testing.T) {
}()
// Expect the workspace creation confirmation
stdout.ExpectMatchContext(ctx, "coder_external_agent.main")
stdout.ExpectMatchContext(ctx, "external-agent (linux, amd64)")
stdout.ExpectMatchContext(ctx, "Confirm create")
stdout.ExpectMatch(ctx, "coder_external_agent.main")
stdout.ExpectMatch(ctx, "external-agent (linux, amd64)")
stdout.ExpectMatch(ctx, "Confirm create")
stdin.WriteLine("yes")
// Expect the external agent instructions
stdout.ExpectMatchContext(ctx, "Please run the following command to attach external agent")
stdout.ExpectRegexMatchContext(ctx, "curl -fsSL .* | CODER_AGENT_TOKEN=.* sh")
stdout.ExpectMatch(ctx, "Please run the following command to attach external agent")
stdout.ExpectRegexMatch(ctx, "curl -fsSL .* | CODER_AGENT_TOKEN=.* sh")
testutil.TryReceive(ctx, t, doneChan)
@@ -229,8 +229,8 @@ func TestExternalWorkspaces(t *testing.T) {
assert.NoError(t, errC)
close(done)
}()
stdout.ExpectMatchContext(ctx, ws.Name)
stdout.ExpectMatchContext(ctx, template.Name)
stdout.ExpectMatch(ctx, ws.Name)
stdout.ExpectMatch(ctx, template.Name)
cancelFunc()
<-done
})
@@ -308,8 +308,8 @@ func TestExternalWorkspaces(t *testing.T) {
assert.NoError(t, errC)
close(done)
}()
stdout.ExpectMatchContext(ctx, "No workspaces found!")
stdout.ExpectMatchContext(ctx, "coder external-workspaces create")
stdout.ExpectMatch(ctx, "No workspaces found!")
stdout.ExpectMatch(ctx, "coder external-workspaces create")
cancelFunc()
<-done
})
@@ -352,8 +352,8 @@ func TestExternalWorkspaces(t *testing.T) {
assert.NoError(t, errC)
close(done)
}()
stdout.ExpectMatchContext(ctx, "Please run the following command to attach external agent to the workspace")
stdout.ExpectRegexMatchContext(ctx, "curl -fsSL .* | CODER_AGENT_TOKEN=.* sh")
stdout.ExpectMatch(ctx, "Please run the following command to attach external agent to the workspace")
stdout.ExpectRegexMatch(ctx, "curl -fsSL .* | CODER_AGENT_TOKEN=.* sh")
cancelFunc()
ctx = testutil.Context(t, testutil.WaitLong)
@@ -503,12 +503,12 @@ func TestExternalWorkspaces(t *testing.T) {
}()
// Expect the workspace creation confirmation
stdout.ExpectMatchContext(ctx, "coder_external_agent.main")
stdout.ExpectMatchContext(ctx, "external-agent (linux, amd64)")
stdout.ExpectMatch(ctx, "coder_external_agent.main")
stdout.ExpectMatch(ctx, "external-agent (linux, amd64)")
// Expect the external agent instructions
stdout.ExpectMatchContext(ctx, "Please run the following command to attach external agent")
stdout.ExpectRegexMatchContext(ctx, "curl -fsSL .* | CODER_AGENT_TOKEN=.* sh")
stdout.ExpectMatch(ctx, "Please run the following command to attach external agent")
stdout.ExpectRegexMatch(ctx, "curl -fsSL .* | CODER_AGENT_TOKEN=.* sh")
testutil.TryReceive(ctx, t, doneChan)
+2 -2
View File
@@ -27,8 +27,8 @@ func TestFeaturesList(t *testing.T) {
clitest.SetupConfig(t, anotherClient, conf)
stdout := expecter.NewAttachedToInvocation(t, inv)
clitest.Start(t, inv)
stdout.ExpectMatchContext(ctx, "user_limit")
stdout.ExpectMatchContext(ctx, "not_entitled")
stdout.ExpectMatch(ctx, "user_limit")
stdout.ExpectMatch(ctx, "not_entitled")
})
t.Run("JSON", func(t *testing.T) {
t.Parallel()
+1 -1
View File
@@ -48,6 +48,6 @@ func TestCreateGroup(t *testing.T) {
err := inv.Run()
require.NoError(t, err)
stdout.ExpectMatchContext(ctx, fmt.Sprintf("Successfully created group %s!", pretty.Sprint(cliui.DefaultStyles.Keyword, groupName)))
stdout.ExpectMatch(ctx, fmt.Sprintf("Successfully created group %s!", pretty.Sprint(cliui.DefaultStyles.Keyword, groupName)))
})
}
+1 -1
View File
@@ -44,7 +44,7 @@ func TestGroupDelete(t *testing.T) {
err := inv.Run()
require.NoError(t, err)
stdout.ExpectMatchContext(ctx, fmt.Sprintf("Successfully deleted group %s", pretty.Sprint(cliui.DefaultStyles.Keyword, group.Name)))
stdout.ExpectMatch(ctx, fmt.Sprintf("Successfully deleted group %s", pretty.Sprint(cliui.DefaultStyles.Keyword, group.Name)))
})
t.Run("NoArg", func(t *testing.T) {
+1 -1
View File
@@ -56,7 +56,7 @@ func TestGroupEdit(t *testing.T) {
err := inv.Run()
require.NoError(t, err)
stdout.ExpectMatchContext(ctx, fmt.Sprintf("Successfully patched group %s", pretty.Sprint(cliui.DefaultStyles.Keyword, expectedName)))
stdout.ExpectMatch(ctx, fmt.Sprintf("Successfully patched group %s", pretty.Sprint(cliui.DefaultStyles.Keyword, expectedName)))
})
t.Run("InvalidUserInput", func(t *testing.T) {
+2 -2
View File
@@ -55,7 +55,7 @@ func TestGroupList(t *testing.T) {
}
for _, match := range matches {
stdout.ExpectMatchContext(ctx, match)
stdout.ExpectMatch(ctx, match)
}
})
@@ -84,7 +84,7 @@ func TestGroupList(t *testing.T) {
}
for _, match := range matches {
stdout.ExpectMatchContext(ctx, match)
stdout.ExpectMatch(ctx, match)
}
})
+6 -6
View File
@@ -40,7 +40,7 @@ func TestLicensesAddFake(t *testing.T) {
stdout := expecter.NewAttachedToInvocation(t, inv)
clitest.Start(t, inv)
ctx := testutil.Context(t, testutil.WaitMedium)
stdout.ExpectMatchContext(ctx, "License with ID 1 added")
stdout.ExpectMatch(ctx, "License with ID 1 added")
})
t.Run("Prompt", func(t *testing.T) {
t.Parallel()
@@ -53,10 +53,10 @@ func TestLicensesAddFake(t *testing.T) {
go func() {
errC <- inv.WithContext(ctx).Run()
}()
stdout.ExpectMatchContext(ctx, "Paste license:")
stdout.ExpectMatch(ctx, "Paste license:")
stdin.WriteLine(fakeLicenseJWT)
require.NoError(t, <-errC)
stdout.ExpectMatchContext(ctx, "License with ID 1 added")
stdout.ExpectMatch(ctx, "License with ID 1 added")
})
t.Run("File", func(t *testing.T) {
t.Parallel()
@@ -72,7 +72,7 @@ func TestLicensesAddFake(t *testing.T) {
errC <- inv.WithContext(ctx).Run()
}()
require.NoError(t, <-errC)
stdout.ExpectMatchContext(ctx, "License with ID 1 added")
stdout.ExpectMatch(ctx, "License with ID 1 added")
})
t.Run("StdIn", func(t *testing.T) {
t.Parallel()
@@ -109,7 +109,7 @@ func TestLicensesAddFake(t *testing.T) {
errC <- inv.WithContext(ctx).Run()
}()
require.NoError(t, <-errC)
stdout.ExpectMatchContext(ctx, "\"f2\": 2")
stdout.ExpectMatch(ctx, "\"f2\": 2")
})
}
@@ -205,7 +205,7 @@ func TestLicensesDeleteFake(t *testing.T) {
clitest.Start(t, inv)
ctx := testutil.Context(t, testutil.WaitMedium)
stdout.ExpectMatchContext(ctx, "License with ID 55 deleted")
stdout.ExpectMatch(ctx, "License with ID 55 deleted")
})
}
+2 -2
View File
@@ -144,7 +144,7 @@ func TestShowOrganizations(t *testing.T) {
errC <- inv.Run()
}()
require.NoError(t, <-errC)
stdout.ExpectMatchContext(ctx, first.OrganizationID.String())
stdout.ExpectMatch(ctx, first.OrganizationID.String())
})
t.Run("UsingFlag", func(t *testing.T) {
@@ -185,7 +185,7 @@ func TestShowOrganizations(t *testing.T) {
errC <- inv.Run()
}()
require.NoError(t, <-errC)
stdout.ExpectMatchContext(ctx, orgs["bar"].ID.String())
stdout.ExpectMatch(ctx, orgs["bar"].ID.String())
})
}
+1 -1
View File
@@ -483,7 +483,7 @@ func TestSchedulePrebuilds(t *testing.T) {
require.NoError(t, inv.Run())
// Then: the updated schedule should be shown
stdout.ExpectMatchContext(ctx, workspace.OwnerName+"/"+workspace.Name)
stdout.ExpectMatch(ctx, workspace.OwnerName+"/"+workspace.Name)
})
}
}
+10 -10
View File
@@ -47,7 +47,7 @@ func TestProvisionerDaemon_PSK(t *testing.T) {
defer cancel()
clitest.Start(t, inv)
stdout.ExpectNoMatchBefore(ctx, "check entitlement", "starting provisioner daemon")
stdout.ExpectMatchContext(ctx, "matt-daemon")
stdout.ExpectMatch(ctx, "matt-daemon")
var daemons []codersdk.ProvisionerDaemon
require.Eventually(t, func() bool {
@@ -82,7 +82,7 @@ func TestProvisionerDaemon_PSK(t *testing.T) {
ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong)
defer cancel()
clitest.Start(t, inv)
stdout.ExpectMatchContext(ctx, "starting provisioner daemon")
stdout.ExpectMatch(ctx, "starting provisioner daemon")
})
t.Run("NoUserNoPSK", func(t *testing.T) {
@@ -124,7 +124,7 @@ func TestProvisionerDaemon_SessionToken(t *testing.T) {
ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong)
defer cancel()
clitest.Start(t, inv)
stdout.ExpectMatchContext(ctx, "starting provisioner daemon")
stdout.ExpectMatch(ctx, "starting provisioner daemon")
var daemons []codersdk.ProvisionerDaemon
var err error
@@ -159,7 +159,7 @@ func TestProvisionerDaemon_SessionToken(t *testing.T) {
ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong)
defer cancel()
clitest.Start(t, inv)
stdout.ExpectMatchContext(ctx, "starting provisioner daemon")
stdout.ExpectMatch(ctx, "starting provisioner daemon")
var daemons []codersdk.ProvisionerDaemon
var err error
@@ -195,7 +195,7 @@ func TestProvisionerDaemon_SessionToken(t *testing.T) {
ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong)
defer cancel()
clitest.Start(t, inv)
stdout.ExpectMatchContext(ctx, "starting provisioner daemon")
stdout.ExpectMatch(ctx, "starting provisioner daemon")
var daemons []codersdk.ProvisionerDaemon
var err error
@@ -231,7 +231,7 @@ func TestProvisionerDaemon_SessionToken(t *testing.T) {
ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong)
defer cancel()
clitest.Start(t, inv)
stdout.ExpectMatchContext(ctx, "starting provisioner daemon")
stdout.ExpectMatch(ctx, "starting provisioner daemon")
var daemons []codersdk.ProvisionerDaemon
var err error
@@ -278,7 +278,7 @@ func TestProvisionerDaemon_ProvisionerKey(t *testing.T) {
stdout := expecter.NewAttachedToInvocation(t, inv)
clitest.Start(t, inv)
stdout.ExpectNoMatchBefore(ctx, "check entitlement", "starting provisioner daemon")
stdout.ExpectMatchContext(ctx, "matt-daemon")
stdout.ExpectMatch(ctx, "matt-daemon")
var daemons []codersdk.ProvisionerDaemon
require.Eventually(t, func() bool {
@@ -323,7 +323,7 @@ func TestProvisionerDaemon_ProvisionerKey(t *testing.T) {
stdout := expecter.NewAttachedToInvocation(t, inv)
clitest.Start(t, inv)
stdout.ExpectNoMatchBefore(ctx, "check entitlement", "starting provisioner daemon")
stdout.ExpectMatchContext(ctx, `tags={"tag1":"value1","tag2":"value2"}`)
stdout.ExpectMatch(ctx, `tags={"tag1":"value1","tag2":"value2"}`)
var daemons []codersdk.ProvisionerDaemon
require.Eventually(t, func() bool {
@@ -439,7 +439,7 @@ func TestProvisionerDaemon_ProvisionerKey(t *testing.T) {
stdout := expecter.NewAttachedToInvocation(t, inv)
clitest.Start(t, inv)
stdout.ExpectNoMatchBefore(ctx, "check entitlement", "starting provisioner daemon")
stdout.ExpectMatchContext(ctx, "matt-daemon")
stdout.ExpectMatch(ctx, "matt-daemon")
var daemons []codersdk.ProvisionerDaemon
require.Eventually(t, func() bool {
daemons, err = client.OrganizationProvisionerDaemons(ctx, anotherOrg.ID, nil)
@@ -479,7 +479,7 @@ func TestProvisionerDaemon_PrometheusEnabled(t *testing.T) {
// Start "provisionerd" command
clitest.Start(t, inv)
stdout.ExpectMatchContext(ctx, "starting provisioner daemon")
stdout.ExpectMatch(ctx, "starting provisioner daemon")
var daemons []codersdk.ProvisionerDaemon
var err error
+1 -1
View File
@@ -107,7 +107,7 @@ func TestWorkspaceProxy_Server_PrometheusEnabled(t *testing.T) {
clitest.StartWithAssert(t, inv, func(t *testing.T, err error) {
// actually no assertions are needed as the test verifies only Prometheus endpoint
})
stdout.ExpectMatchContext(ctx, "Started HTTP listener at")
stdout.ExpectMatch(ctx, "Started HTTP listener at")
// Fetch metrics from Prometheus endpoint
var res *http.Response
+1 -1
View File
@@ -64,7 +64,7 @@ func Test_ProxyCRUD(t *testing.T) {
err = inv.WithContext(ctx).Run()
require.NoError(t, err)
stdout.ExpectMatchContext(ctx, expectedName)
stdout.ExpectMatch(ctx, expectedName)
// Also check via the api
proxies, err := client.WorkspaceProxies(ctx) //nolint:gocritic // requires owner