| 10 | ) |
| 11 | |
| 12 | func TestNewIssue(t *testing.T) { |
| 13 | t.Run("nil input", func(t *testing.T) { |
| 14 | a := require.New(t) |
| 15 | a.Nil(NewIssue(nil)) |
| 16 | }) |
| 17 | |
| 18 | t.Run("basic fields", func(t *testing.T) { |
| 19 | a := require.New(t) |
| 20 | msg := &store.IssueMessage{ |
| 21 | UID: 42, |
| 22 | Title: "Add index to users table", |
| 23 | Description: "We need a B-tree index", |
| 24 | Status: storepb.Issue_OPEN, |
| 25 | Type: storepb.Issue_DATABASE_CHANGE, |
| 26 | CreatorEmail: "alice@example.com", |
| 27 | Payload: &storepb.Issue{}, |
| 28 | } |
| 29 | got := NewIssue(msg) |
| 30 | a.Equal(int64(42), got.UID) |
| 31 | a.Equal("Add index to users table", got.Title) |
| 32 | a.Equal("We need a B-tree index", got.Description) |
| 33 | a.Equal("OPEN", got.Status) |
| 34 | a.Equal("DATABASE_CHANGE", got.Type) |
| 35 | a.Equal("alice@example.com", got.CreatorEmail) |
| 36 | }) |
| 37 | |
| 38 | t.Run("nil payload", func(t *testing.T) { |
| 39 | a := require.New(t) |
| 40 | msg := &store.IssueMessage{ |
| 41 | UID: 1, |
| 42 | Title: "test", |
| 43 | } |
| 44 | got := NewIssue(msg) |
| 45 | a.NotNil(got) |
| 46 | a.Nil(got.Approval) |
| 47 | }) |
| 48 | } |
| 49 | |
| 50 | func TestNewProject(t *testing.T) { |
| 51 | a := require.New(t) |