-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathappsync_test.go
49 lines (40 loc) · 965 Bytes
/
appsync_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package appsync
import (
"context"
"log"
"net/http"
"os"
"testing"
"github.com/sony/appsync-client-go/graphql"
)
type ret struct {
response *graphql.Response
err error
}
type testGraphQLAPI struct {
header http.Header
request graphql.PostRequest
}
func (t *testGraphQLAPI) Post(header http.Header, request graphql.PostRequest) (*graphql.Response, error) {
t.header = header
t.request = request
return &testResponse, nil
}
func (t *testGraphQLAPI) PostAsync(header http.Header, request graphql.PostRequest, callback func(*graphql.Response, error)) (context.CancelFunc, error) {
t.header = header
t.request = request
go func() {
callback(&testResponse, nil)
}()
return func() {}, nil
}
func (t *testGraphQLAPI) GetPostedHeader() http.Header {
return t.header
}
func (t *testGraphQLAPI) GetPostedPostRequest() graphql.PostRequest {
return t.request
}
func TestMain(m *testing.M) {
log.SetFlags(log.Lshortfile)
os.Exit(m.Run())
}