github.com/optim-corp/cios-golang-sdk@v0.5.1/sdk/service_account_me_test.go (about) 1 package ciossdk 2 3 import ( 4 "context" 5 "encoding/json" 6 "net/http" 7 "net/http/httptest" 8 "testing" 9 10 "github.com/optim-corp/cios-golang-sdk/cios" 11 sdkmodel "github.com/optim-corp/cios-golang-sdk/model" 12 ) 13 14 func TestAccount_GetMe(t *testing.T) { 15 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 16 w.Header().Set("Content-Type", "application/json") 17 if r.Method != "GET" { 18 t.Fatal(r.Method) 19 } 20 if r.URL.Path == "/v2/me" { 21 response := cios.Me{ 22 Id: "test", 23 } 24 json.NewEncoder(w).Encode(response) 25 } 26 })) 27 defer ts.Close() 28 client := NewCiosClient(CiosClientConfig{Urls: sdkmodel.CIOSUrl{AccountsUrl: ts.URL}}) 29 responseB, response, err := client.Account().GetMe(context.Background()) 30 if responseB.Id != "test" || err != nil || response.StatusCode != 200 { 31 t.Fatal(responseB) 32 } 33 }