internal/control/issue_test.go
34 lines · 1122 bytes
1package control
2
3import "testing"
4
5func TestIssueAssignNotifiesTheAssignee(t *testing.T) {
6 c, repo, bob := testRepoWithWatcher(t)
7
8 if code := runIssueAssign(c, []string{repo.Path(), "1", "--add", "bob"}); code != 0 {
9 t.Fatalf("exit %d", code)
10 }
11 rows, _ := c.Store.Inbox(bob, false, 20, 0)
12 if len(rows) != 1 || rows[0].Summary != "assigned you to #1" {
13 t.Fatalf("got %+v", rows)
14 }
15}
16
17func TestIssueAssignIsSilentForTheActorAndForRemovals(t *testing.T) {
18 c, repo, bob := testRepoWithWatcher(t)
19
20 // Assigning yourself announces nothing: notify drops the actor.
21 runIssueAssign(c, []string{repo.Path(), "1", "--add", "alice"})
22 if rows, _ := c.Store.Inbox(c.User.ID, false, 20, 0); len(rows) != 0 {
23 t.Fatalf("self-assignment notified: %+v", rows)
24 }
25
26 // Unassigning files nothing.
27 runIssueAssign(c, []string{repo.Path(), "1", "--add", "bob"})
28 before, _ := c.Store.Inbox(bob, false, 20, 0)
29 runIssueAssign(c, []string{repo.Path(), "1", "--remove", "bob"})
30 after, _ := c.Store.Inbox(bob, false, 20, 0)
31 if len(after) != len(before) {
32 t.Fatalf("removal filed a row: %d then %d", len(before), len(after))
33 }
34}