test server
This commit is contained in:
parent
594708b656
commit
11e2501455
31
cmd/mstdn/cmd_test.go
Normal file
31
cmd/mstdn/cmd_test.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
||||
"github.com/mattn/go-mastodon"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func testWithServer(h http.HandlerFunc, testFunc func(*cli.App)) string {
|
||||
ts := httptest.NewServer(h)
|
||||
defer ts.Close()
|
||||
|
||||
client := mastodon.NewClient(&mastodon.Config{
|
||||
Server: ts.URL,
|
||||
ClientID: "foo",
|
||||
ClientSecret: "bar",
|
||||
AccessToken: "zoo",
|
||||
})
|
||||
|
||||
var buf bytes.Buffer
|
||||
app := makeApp()
|
||||
app.Writer = &buf
|
||||
app.Metadata = map[string]interface{}{
|
||||
"client": client,
|
||||
}
|
||||
testFunc(app)
|
||||
return buf.String()
|
||||
}
|
Loading…
Reference in New Issue
Block a user