37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package tencentim
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"chatapp3-golang/internal/config"
|
|
)
|
|
|
|
func TestCreateGroupTreatsDuplicateAsSuccess(t *testing.T) {
|
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if r.URL.Path != "/v4/group_open_http_svc/create_group" {
|
|
t.Fatalf("path = %s", r.URL.Path)
|
|
}
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_, _ = w.Write([]byte(`{"ActionStatus":"FAIL","ErrorCode":10021,"ErrorInfo":"group id has been used"}`))
|
|
}))
|
|
defer server.Close()
|
|
|
|
client := NewClient(config.TencentIMConfig{
|
|
AppID: 123456,
|
|
Key: "secret",
|
|
Identifier: "administrator",
|
|
BaseEndpoint: server.URL,
|
|
RequestTimeoutSeconds: 1,
|
|
})
|
|
groupID, err := client.CreateAVChatRoom(context.Background(), "VRRP_LIKEI_AR", "region-ar")
|
|
if err != nil {
|
|
t.Fatalf("CreateAVChatRoom() error = %v", err)
|
|
}
|
|
if groupID != "VRRP_LIKEI_AR" {
|
|
t.Fatalf("groupID = %s, want VRRP_LIKEI_AR", groupID)
|
|
}
|
|
}
|