github.com/optim-corp/cios-golang-sdk@v0.5.1/sdk/service_account_member_test.go (about) 1 package ciossdk 2 3 import ( 4 "context" 5 "io/ioutil" 6 "net/http" 7 "net/http/httptest" 8 "testing" 9 10 cnv "github.com/fcfcqloow/go-advance/convert" 11 "github.com/optim-corp/cios-golang-sdk/cios" 12 sdkmodel "github.com/optim-corp/cios-golang-sdk/model" 13 ) 14 15 func TestAccount_InviteGroup(t *testing.T) { 16 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 17 w.Header().Set("Content-Type", "application/json") 18 body := cios.GroupInviteRequest{} 19 byt, _ := ioutil.ReadAll(r.Body) 20 cnv.UnMarshalJson(byt, &body) 21 if *body.Email != "email@temp.com" { 22 t.Fatal(body) 23 } 24 if r.URL.Path != "/v2/groups/id/invites" { 25 t.Fatal(r.URL.Path) 26 } 27 if r.Method != "POST" { 28 t.Fatal(r.Method) 29 } 30 })) 31 defer ts.Close() 32 client := NewCiosClient(CiosClientConfig{Urls: sdkmodel.CIOSUrl{AccountsUrl: ts.URL}}) 33 _, _, err := client.Account().InviteGroup(context.Background(), "id", "email@temp.com") 34 if err != nil { 35 t.Fatal(err.Error()) 36 } 37 }