Skip to content

Commit

Permalink
Merge pull request #1080 from pmenglund/sharedLinks
Browse files Browse the repository at this point in the history
sharedLinks struct should be exported
  • Loading branch information
kanata2 committed Sep 11, 2022
2 parents 6f5eda2 + 62ab20d commit 78e593a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions slackevents/inner_events.go
Expand Up @@ -178,11 +178,11 @@ type LinkSharedEvent struct {
// compose text area.
MessageTimeStamp string `json:"message_ts"`
ThreadTimeStamp string `json:"thread_ts"`
Links []sharedLinks `json:"links"`
Links []SharedLinks `json:"links"`
EventTimestamp string `json:"event_ts"`
}

type sharedLinks struct {
type SharedLinks struct {
Domain string `json:"domain"`
URL string `json:"url"`
}
Expand Down
28 changes: 28 additions & 0 deletions slackevents/inner_events_test.go
Expand Up @@ -103,6 +103,34 @@ func TestLinkSharedEvent(t *testing.T) {
}
}

func TestLinkSharedEvent_struct(t *testing.T) {
e := LinkSharedEvent{
Type: "link_shared",
User: "Uxxxxxxx",
TimeStamp: "123456789.9876",
Channel: "Cxxxxxx",
MessageTimeStamp: "123456789.9875",
ThreadTimeStamp: "123456789.9876",
Links: []SharedLinks{
{Domain: "example.com", URL: "https://example.com/12345"},
{Domain: "example.com", URL: "https://example.com/67890"},
{Domain: "another-example.com", URL: "https://yet.another-example.com/v/abcde"},
},
EventTimestamp: "123456789.9876",
}
rawE, err := json.Marshal(e)
if err != nil {
t.Error(err)
}
expected := `{"type":"link_shared","user":"Uxxxxxxx","ts":"123456789.9876","channel":"Cxxxxxx",` +
`"message_ts":"123456789.9875","thread_ts":"123456789.9876","links":[{"domain":"example.com",` +
`"url":"https://example.com/12345"},{"domain":"example.com","url":"https://example.com/67890"},` +
`{"domain":"another-example.com","url":"https://yet.another-example.com/v/abcde"}],"event_ts":"123456789.9876"}`
if string(rawE) != expected {
t.Errorf("expected %s, but got %s", expected, string(rawE))
}
}

func TestLinkSharedComposerEvent(t *testing.T) {
rawE := []byte(`
{
Expand Down

0 comments on commit 78e593a

Please sign in to comment.