Skip to content

Commit

Permalink
More tests and fix OrgAssets.TopicByID
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Aug 25, 2021
1 parent 6a5f41b commit 878ce9c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/handlers/ticket_opened_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func TestTicketOpened(t *testing.T) {
actions.NewOpenTicket(
handlers.NewActionUUID(),
assets.NewTicketerReference(testdata.Mailgun.UUID, "Mailgun (IT Support)"),
nil,
"Need help",
assets.NewTopicReference(testdata.SupportTopic.UUID, "Support"),
"",
"Where are my cookies?",
assets.NewUserReference(testdata.Admin.Email, "Admin"),
"Email Ticket",
Expand Down
1 change: 1 addition & 0 deletions core/models/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ func NewOrgAssets(ctx context.Context, db *sqlx.DB, orgID OrgID, prev *OrgAssets
oa.topicsByID = make(map[TopicID]*Topic, len(oa.topics))
oa.topicsByUUID = make(map[assets.TopicUUID]*Topic, len(oa.topics))
for _, t := range oa.topics {
oa.topicsByID[t.(*Topic).ID()] = t.(*Topic)
oa.topicsByUUID[t.UUID()] = t.(*Topic)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/models/tickets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestTickets(t *testing.T) {
testdata.Bob.ID,
testdata.Zendesk.ID,
"EX7869",
testdata.DefaultTopic.ID,
testdata.SalesTopic.ID,
"New Zen Ticket",
"Where are my trousers?",
models.NilUserID,
Expand Down
9 changes: 8 additions & 1 deletion core/models/topics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ func TestTopics(t *testing.T) {
topics, err := oa.Topics()
require.NoError(t, err)

assert.Equal(t, 1, len(topics))
assert.Equal(t, 3, len(topics))
assert.Equal(t, testdata.DefaultTopic.UUID, topics[0].UUID())
assert.Equal(t, "General", topics[0].Name())
assert.Equal(t, testdata.SalesTopic.UUID, topics[1].UUID())
assert.Equal(t, "Sales", topics[1].Name())
assert.Equal(t, testdata.SupportTopic.UUID, topics[2].UUID())
assert.Equal(t, "Support", topics[2].Name())

assert.Equal(t, topics[1], oa.TopicByID(testdata.SalesTopic.ID))
assert.Equal(t, topics[2], oa.TopicByUUID(testdata.SupportTopic.UUID))
}
Binary file modified mailroom_test.dump
Binary file not shown.
2 changes: 2 additions & 0 deletions testsuite/testdata/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ var ReportingLabel = &Label{10000, "ebc4dedc-91c4-4ed4-9dd6-daa05ea82698"}
var TestingLabel = &Label{10001, "a6338cdc-7938-4437-8b05-2d5d785e3a08"}

var DefaultTopic = &Topic{1, "ffc903f7-8cbb-443f-9627-87106842d1aa"}
var SalesTopic = &Topic{2, "9ef2ff21-064a-41f1-8560-ccc990b4f937"}
var SupportTopic = &Topic{3, "0a8f2e00-fef6-402c-bd79-d789446ec0e0"}

var Internal = &Ticketer{1, "8bd48029-6ca1-46a8-aa14-68f7213b82b3"}
var Mailgun = &Ticketer{2, "f9c9447f-a291-4f3c-8c79-c089bbd4e713"}
Expand Down

0 comments on commit 878ce9c

Please sign in to comment.