2017-04-16 16:52:32 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCmdFollowers(t *testing.T) {
|
|
|
|
out := testWithServer(
|
|
|
|
func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
switch r.URL.Path {
|
|
|
|
case "/api/v1/accounts/verify_credentials":
|
|
|
|
fmt.Fprintln(w, `{"id": 123}`)
|
|
|
|
return
|
|
|
|
case "/api/v1/accounts/123/followers":
|
2017-05-04 17:18:17 +02:00
|
|
|
w.Header().Set("Link", `<http://example.com?since_id=890>; rel="prev"`)
|
2017-04-19 16:32:23 +02:00
|
|
|
fmt.Fprintln(w, `[{"id": 234, "username": "ZZZ", "acct": "zzz"}]`)
|
2017-04-16 16:52:32 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
|
|
|
return
|
|
|
|
},
|
|
|
|
func(app *cli.App) {
|
|
|
|
app.Run([]string{"mstdn", "followers"})
|
|
|
|
},
|
|
|
|
)
|
|
|
|
if !strings.Contains(out, "zzz") {
|
2017-04-16 17:00:12 +02:00
|
|
|
t.Fatalf("%q should be contained in output of command: %v", "zzz", out)
|
2017-04-16 16:52:32 +02:00
|
|
|
}
|
|
|
|
}
|