MCPcopy Create free account
hub / github.com/bluekeyes/patch2pr / prepareTestContext

Function prepareTestContext

applier_test.go:221–254  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

219}
220
221func prepareTestContext(t *testing.T) *TestContext {
222 id := strconv.FormatInt(time.Now().UnixNano()/1000000, 10)
223
224 fullRepo, ok := os.LookupEnv(EnvRepo)
225 if !ok || fullRepo == "" {
226 t.Skipf("%s must be set in the environment", EnvRepo)
227 }
228 token, ok := os.LookupEnv(EnvToken)
229 if !ok || token == "" {
230 t.Skipf("%s must be set in the environment", EnvToken)
231 }
232
233 repo, err := ParseRepository(fullRepo)
234 if err != nil {
235 t.Fatalf("Invalid %s value: %v", EnvRepo, err)
236 }
237
238 ctx := context.Background()
239 httpClient := internal.NewTokenClient(token)
240
241 client, err := github.NewClient(github.WithHTTPClient(httpClient))
242 if err != nil {
243 t.Fatalf("Error creating GitHub client: %v", err)
244 }
245
246 tctx := TestContext{
247 Context: ctx,
248 ID: id,
249 Repo: repo,
250 Client: client,
251 V4Client: githubv4.NewClient(httpClient),
252 }
253 return &tctx
254}
255
256func createBranch(t *testing.T, tctx *TestContext) {
257 root := filepath.Join("testdata", "base") + string(filepath.Separator)

Callers 2

TestGraphQLApplierFunction · 0.85
TestApplierFunction · 0.85

Calls 2

NewTokenClientFunction · 0.92
ParseRepositoryFunction · 0.85

Tested by

no test coverage detected