-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1216 from nopcoder/master
Sends an invitation to a Slack Connect channel
- Loading branch information
Showing
5 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,6 +287,20 @@ func okChannelJsonHandler(rw http.ResponseWriter, r *http.Request) { | |
rw.Write(response) | ||
} | ||
|
||
func okInviteSharedJsonHandler(rw http.ResponseWriter, r *http.Request) { | ||
rw.Header().Set("Content-Type", "application/json") | ||
response, _ := json.Marshal(struct { | ||
SlackResponse | ||
InviteID string `json:"invite_id"` | ||
IsLegacySharedChannel bool `json:"is_legacy_shared_channel"` | ||
}{ | ||
SlackResponse: SlackResponse{Ok: true}, | ||
InviteID: "I01234567", | ||
IsLegacySharedChannel: false, | ||
}) | ||
rw.Write(response) | ||
} | ||
|
||
func TestSetTopicOfConversation(t *testing.T) { | ||
http.HandleFunc("/conversations.setTopic", okChannelJsonHandler) | ||
once.Do(startServer) | ||
|
@@ -348,6 +362,44 @@ func TestInviteUsersToConversation(t *testing.T) { | |
} | ||
} | ||
|
||
func TestInviteSharedToConversation(t *testing.T) { | ||
http.HandleFunc("/conversations.inviteShared", okInviteSharedJsonHandler) | ||
once.Do(startServer) | ||
api := New("testing-token", OptionAPIURL("http://"+serverAddr+"/")) | ||
|
||
t.Run("user_ids", func(t *testing.T) { | ||
userIDs := []string{"UXXXXXXX1", "UXXXXXXX2"} | ||
inviteID, isLegacySharedChannel, err := api.InviteSharedUserIDsToConversation("CXXXXXXXX", userIDs...) | ||
if err != nil { | ||
t.Errorf("Unexpected error: %s", err) | ||
return | ||
} | ||
if inviteID == "" { | ||
t.Error("invite id should have a value") | ||
return | ||
} | ||
if isLegacySharedChannel { | ||
t.Error("is legacy shared channel should be false") | ||
} | ||
}) | ||
|
||
t.Run("emails", func(t *testing.T) { | ||
emails := []string{"[email protected]", "[email protected]"} | ||
inviteID, isLegacySharedChannel, err := api.InviteSharedEmailsToConversation("CXXXXXXXX", emails...) | ||
if err != nil { | ||
t.Errorf("Unexpected error: %s", err) | ||
return | ||
} | ||
if inviteID == "" { | ||
t.Error("invite id should have a value") | ||
return | ||
} | ||
if isLegacySharedChannel { | ||
t.Error("is legacy shared channel should be false") | ||
} | ||
}) | ||
} | ||
|
||
func TestKickUserFromConversation(t *testing.T) { | ||
http.HandleFunc("/conversations.kick", okJSONHandler) | ||
once.Do(startServer) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters