MCPcopy Create free account
hub / github.com/git-bug/git-bug / NewTestEnvAndUser

Function NewTestEnvAndUser

commands/bug/testenv/testenv.go:18–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func NewTestEnvAndUser(t *testing.T) (*execenv.Env, entity.Id) {
19 t.Helper()
20
21 // The Go testing framework either uses os.Stdout directly or a buffer
22 // depending on how the command is initially launched. This results
23 // in os.Stdout.Fd() sometimes being a Terminal, and other times not
24 // being a Terminal which determines whether the ANSI library sends
25 // escape sequences to colorize the text.
26 //
27 // The line below disables all colorization during testing so that the
28 // git-bug command output is consistent in all test scenarios.
29 //
30 // See:
31 // - https://github.com/git-bug/git-bug/issues/926
32 // - https://github.com/golang/go/issues/57671
33 // - https://github.com/golang/go/blob/f721fa3be9bb52524f97b409606f9423437535e8/src/cmd/go/internal/test/test.go#L1180-L1208
34 // - https://github.com/golang/go/issues/34877
35 color.NoColor = true
36
37 testEnv := execenv.NewTestEnv(t)
38
39 i, err := testEnv.Backend.Identities().New(testUserName, testUserEmail)
40 require.NoError(t, err)
41
42 err = testEnv.Backend.SetUserIdentity(i)
43 require.NoError(t, err)
44
45 return testEnv, i.Id()
46}
47
48const (
49 testBugTitle = "this is a bug title"

Callers 3

TestUserNewCommandFunction · 0.92
TestBugNewFunction · 0.92
NewTestEnvAndBugFunction · 0.85

Calls 6

NewTestEnvFunction · 0.92
HelperMethod · 0.80
IdentitiesMethod · 0.80
SetUserIdentityMethod · 0.80
IdMethod · 0.65
NewMethod · 0.45

Tested by 2

TestUserNewCommandFunction · 0.74
TestBugNewFunction · 0.74