diff options
author | Michael Muré <batolettre@gmail.com> | 2022-09-10 11:09:19 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2022-11-20 17:18:09 +0100 |
commit | acc9a6f3a6df2961c3ae44352216d915cb9b5315 (patch) | |
tree | e159372673104ade1f15ddc1a84aa9da93e93552 /commands/bug/testenv | |
parent | a3fa445a9c76631c4cd16f93e1c1c68a954adef7 (diff) | |
download | git-bug-acc9a6f3a6df2961c3ae44352216d915cb9b5315.tar.gz |
commands: reorg into different packages
Diffstat (limited to 'commands/bug/testenv')
-rw-r--r-- | commands/bug/testenv/testenv.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/commands/bug/testenv/testenv.go b/commands/bug/testenv/testenv.go new file mode 100644 index 00000000..10f20950 --- /dev/null +++ b/commands/bug/testenv/testenv.go @@ -0,0 +1,63 @@ +package testenv + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/MichaelMure/git-bug/commands/execenv" + "github.com/MichaelMure/git-bug/entity" +) + +const ( + testUserName = "John Doe" + testUserEmail = "jdoe@example.com" +) + +func NewTestEnvAndUser(t *testing.T) (*execenv.Env, entity.Id) { + t.Helper() + + testEnv := execenv.NewTestEnv(t) + + i, err := testEnv.Backend.NewIdentity(testUserName, testUserEmail) + require.NoError(t, err) + + err = testEnv.Backend.SetUserIdentity(i) + require.NoError(t, err) + + return testEnv, i.Id() +} + +const ( + testBugTitle = "this is a bug title" + testBugMessage = "this is a bug message" +) + +func NewTestEnvAndBug(t *testing.T) (*execenv.Env, entity.Id) { + t.Helper() + + testEnv, _ := NewTestEnvAndUser(t) + + b, _, err := testEnv.Backend.NewBug(testBugTitle, testBugMessage) + require.NoError(t, err) + + return testEnv, b.Id() +} + +const ( + testCommentMessage = "this is a bug comment" +) + +func NewTestEnvAndBugWithComment(t *testing.T) (*execenv.Env, entity.Id, entity.CombinedId) { + t.Helper() + + env, bugID := NewTestEnvAndBug(t) + + b, err := env.Backend.ResolveBug(bugID) + require.NoError(t, err) + + commentId, _, err := b.AddComment(testCommentMessage) + require.NoError(t, err) + + return env, bugID, commentId +} |