Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sharedLinks struct should be exported #1080

Merged
merged 3 commits into from Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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