forked from google/go-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapps_manifest_test.go
68 lines (58 loc) · 1.53 KB
/
apps_manifest_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2019 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import (
"context"
"fmt"
"net/http"
"reflect"
"testing"
)
const (
manifestJSON = `{
"id": 1,
"client_id": "a" ,
"client_secret": "b",
"webhook_secret": "c",
"pem": "key"
}
`
)
func TestGetConfig(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/app-manifests/code/conversions", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testHeader(t, r, "Accept", mediaTypeAppManifestPreview)
fmt.Fprint(w, manifestJSON)
})
ctx := context.Background()
cfg, _, err := client.Apps.CompleteAppManifest(ctx, "code")
if err != nil {
t.Errorf("AppManifest.GetConfig returned error: %v", err)
}
want := &AppConfig{
ID: Int64(1),
ClientID: String("a"),
ClientSecret: String("b"),
WebhookSecret: String("c"),
PEM: String("key"),
}
if !reflect.DeepEqual(cfg, want) {
t.Errorf("GetConfig returned %+v, want %+v", cfg, want)
}
const methodName = "CompleteAppManifest"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Apps.CompleteAppManifest(ctx, "\n")
return err
})
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Apps.CompleteAppManifest(ctx, "code")
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}