| 16 | ) |
| 17 | |
| 18 | func 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 | |
| 48 | const ( |
| 49 | testBugTitle = "this is a bug title" |