add test for follow command
parent
93d28c8b04
commit
909a57c5ea
|
@ -0,0 +1,34 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/urfave/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCmdFollow(t *testing.T) {
|
||||||
|
ok := false
|
||||||
|
testWithServer(
|
||||||
|
func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
switch r.URL.Path {
|
||||||
|
case "/api/v1/accounts/search":
|
||||||
|
fmt.Fprintln(w, `[{"id": 123}]`)
|
||||||
|
return
|
||||||
|
case "/api/v1/accounts/123/follow":
|
||||||
|
fmt.Fprintln(w, `{"id": 123}`)
|
||||||
|
ok = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||||
|
return
|
||||||
|
},
|
||||||
|
func(app *cli.App) {
|
||||||
|
app.Run([]string{"mstdn", "follow", "mattn"})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if !ok {
|
||||||
|
t.Fatal("something wrong to sequence to follow account")
|
||||||
|
}
|
||||||
|
}
|
|
@ -239,16 +239,16 @@ func makeApp() *cli.App {
|
||||||
Usage: "search content",
|
Usage: "search content",
|
||||||
Action: cmdSearch,
|
Action: cmdSearch,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Name: "followers",
|
|
||||||
Usage: "show followers",
|
|
||||||
Action: cmdFollowers,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Name: "follow",
|
Name: "follow",
|
||||||
Usage: "follow account",
|
Usage: "follow account",
|
||||||
Action: cmdFollow,
|
Action: cmdFollow,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "followers",
|
||||||
|
Usage: "show followers",
|
||||||
|
Action: cmdFollowers,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "upload",
|
Name: "upload",
|
||||||
Usage: "upload file",
|
Usage: "upload file",
|
||||||
|
|
Loading…
Reference in New Issue