-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathutil_test.go
46 lines (37 loc) · 863 Bytes
/
util_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
package main
import (
"bytes"
"net/http"
"net/http/httptest"
"net/url"
"golang.org/x/oauth2"
"github.com/urfave/cli/v2"
)
func testWithServer(h http.HandlerFunc, testFuncs ...func(*cli.App)) string {
ts := httptest.NewServer(h)
defer ts.Close()
cli.OsExiter = func(n int) {}
uri, _ := url.Parse(ts.URL)
var buf bytes.Buffer
app.Metadata = map[string]interface{}{
"dboxpaper": &DboxPaper{
uri: uri,
token: nil,
config: &oauth2.Config{
Scopes: []string{},
Endpoint: oauth2.Endpoint{
AuthURL: "https://www.dropbox.com/oauth2/authorize",
TokenURL: "https://api.dropboxapi.com/oauth2/token",
},
ClientID: "nrb8y95k7yoeor6",
ClientSecret: "fhme6tzwkzw5og8",
RedirectURL: "http://localhost:8989",
},
},
}
app.Writer = &buf
for _, f := range testFuncs {
f(app)
}
return buf.String()
}