use switch/case
This commit is contained in:
parent
f2ab559a02
commit
88c2fecca2
|
@ -12,11 +12,12 @@ import (
|
||||||
func TestCmdInstance(t *testing.T) {
|
func TestCmdInstance(t *testing.T) {
|
||||||
out := testWithServer(
|
out := testWithServer(
|
||||||
func(w http.ResponseWriter, r *http.Request) {
|
func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Path != "/api/v1/instance" {
|
switch r.URL.Path {
|
||||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
case "/api/v1/instance":
|
||||||
|
fmt.Fprintln(w, `{"title": "zzz"}`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Fprintln(w, `{"title": "zzz"}`)
|
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
},
|
},
|
||||||
func(app *cli.App) {
|
func(app *cli.App) {
|
||||||
|
|
|
@ -12,11 +12,12 @@ import (
|
||||||
func TestCmdNotification(t *testing.T) {
|
func TestCmdNotification(t *testing.T) {
|
||||||
out := testWithServer(
|
out := testWithServer(
|
||||||
func(w http.ResponseWriter, r *http.Request) {
|
func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Path != "/api/v1/notifications" {
|
switch r.URL.Path {
|
||||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
case "/api/v1/notifications":
|
||||||
|
fmt.Fprintln(w, `[{"type": "rebloged", "status": {"content": "foo"}}]`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Fprintln(w, `[{"type": "rebloged", "status": {"content": "foo"}}]`)
|
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
},
|
},
|
||||||
func(app *cli.App) {
|
func(app *cli.App) {
|
||||||
|
|
|
@ -12,11 +12,12 @@ import (
|
||||||
func TestCmdTimeline(t *testing.T) {
|
func TestCmdTimeline(t *testing.T) {
|
||||||
out := testWithServer(
|
out := testWithServer(
|
||||||
func(w http.ResponseWriter, r *http.Request) {
|
func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Path != "/api/v1/timelines/home" {
|
switch r.URL.Path {
|
||||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
case "/api/v1/timelines/home":
|
||||||
|
fmt.Fprintln(w, `[{"content": "zzz"}]`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Fprintln(w, `[{"content": "zzz"}]`)
|
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
},
|
},
|
||||||
func(app *cli.App) {
|
func(app *cli.App) {
|
||||||
|
|
|
@ -12,12 +12,13 @@ func TestCmdToot(t *testing.T) {
|
||||||
toot := ""
|
toot := ""
|
||||||
testWithServer(
|
testWithServer(
|
||||||
func(w http.ResponseWriter, r *http.Request) {
|
func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Path != "/api/v1/statuses" {
|
switch r.URL.Path {
|
||||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
case "/api/v1/statuses":
|
||||||
|
toot = r.FormValue("status")
|
||||||
|
fmt.Fprintln(w, `{"ID": 2345}`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
toot = r.FormValue("status")
|
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||||
fmt.Fprintln(w, `{"ID": 2345}`)
|
|
||||||
return
|
return
|
||||||
},
|
},
|
||||||
func(app *cli.App) {
|
func(app *cli.App) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user