go-mastodon/cmd/mstdn/cmd_delete_test.go
Yasuhiro Matsumoto 1a101faaae add delete command
2017-04-20 02:04:20 +09:00

42 lines
729 B
Go

package main
import (
"fmt"
"net/http"
"testing"
"github.com/urfave/cli"
)
func TestCmdDelete(t *testing.T) {
ok := false
f := func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/api/v1/statuses/123":
fmt.Fprintln(w, `{}`)
ok = true
return
}
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
return
}
testWithServer(
f, func(app *cli.App) {
app.Run([]string{"mstdn", "delete", "122"})
},
)
if ok {
t.Fatal("something wrong to sequence to follow account")
}
ok = false
testWithServer(
f, func(app *cli.App) {
app.Run([]string{"mstdn", "delete", "123"})
},
)
if !ok {
t.Fatal("something wrong to sequence to follow account")
}
}