MCPcopy Create free account
hub / github.com/github/copilot-sdk / ConfigureForTest

Method ConfigureForTest

go/internal/e2e/testharness/context.go:125–159  ·  view source on GitHub ↗

ConfigureForTest configures the proxy for a specific subtest. Call this at the start of each t.Run subtest.

(t *testing.T)

Source from the content-addressed store, hash-verified

123// ConfigureForTest configures the proxy for a specific subtest.
124// Call this at the start of each t.Run subtest.
125func (c *TestContext) ConfigureForTest(t *testing.T) {
126 t.Helper()
127
128 // Format: test/snapshots/<testFile>/<testName>.yaml
129 // e.g., test/snapshots/session/should_have_stateful_conversation.yaml
130
131 // Get the test file name from the caller's file path
132 _, callerFile, _, ok := runtime.Caller(1)
133 if !ok {
134 t.Fatal("Failed to get caller information")
135 }
136
137 // Extract test file name: ask_user_test.go -> ask_user, ask_user_e2e_test.go -> ask_user
138 testFile := strings.TrimSuffix(filepath.Base(callerFile), "_test.go")
139 testFile = strings.TrimSuffix(testFile, "_e2e")
140
141 // Extract and sanitize the subtest name from t.Name()
142 // t.Name() returns "TestAskUser/should_handle_freeform_user_input_response"
143 testName := t.Name()
144 parts := strings.SplitN(testName, "/", 2)
145 if len(parts) < 2 {
146 t.Fatalf("Expected test name with subtest, got: %s", testName)
147 }
148 sanitizedName := strings.ToLower(regexp.MustCompile(`[^a-zA-Z0-9]`).ReplaceAllString(parts[1], "_"))
149 snapshotPath := filepath.Join("..", "..", "..", "test", "snapshots", testFile, sanitizedName+".yaml")
150
151 absSnapshotPath, err := filepath.Abs(snapshotPath)
152 if err != nil {
153 t.Fatalf("Failed to get absolute path: %v", err)
154 }
155
156 if err := c.proxy.Configure(absSnapshotPath, c.WorkDir); err != nil {
157 t.Fatalf("Failed to configure proxy: %v", err)
158 }
159}
160
161// Close cleans up the test context resources.
162func (c *TestContext) Close(testFailed bool) {

Callers 15

TestAbortE2EFunction · 0.95
TestPerSessionAuthE2EFunction · 0.95
TestProviderEndpointE2EFunction · 0.95
TestSuspendE2EFunction · 0.95
TestPendingWorkResumeE2EFunction · 0.95
TestSessionFSE2EFunction · 0.95
TestMultiTurnE2EFunction · 0.95
TestPermissionsE2EFunction · 0.95
TestResumeMCPOAuthE2EFunction · 0.95

Calls 1

ConfigureMethod · 0.45

Tested by 15

TestAbortE2EFunction · 0.76
TestPerSessionAuthE2EFunction · 0.76
TestProviderEndpointE2EFunction · 0.76
TestSuspendE2EFunction · 0.76
TestPendingWorkResumeE2EFunction · 0.76
TestSessionFSE2EFunction · 0.76
TestMultiTurnE2EFunction · 0.76
TestPermissionsE2EFunction · 0.76
TestResumeMCPOAuthE2EFunction · 0.76