Added POST /hello test
This commit is contained in:
rodič
03e0fb07c7
revize
b3fba70b13
|
@ -1,6 +1,7 @@
|
|||
package msgbus
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
@ -59,6 +60,19 @@ func TestServeHTTPGETEmpty(t *testing.T) {
|
|||
assert.Equal(w.Body.String(), "{}")
|
||||
}
|
||||
|
||||
func TestServeHTTPPOST(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
mb := New(nil)
|
||||
w := httptest.NewRecorder()
|
||||
b := bytes.NewBufferString("hello world")
|
||||
r, _ := http.NewRequest("POST", "/hello", b)
|
||||
|
||||
mb.ServeHTTP(w, r)
|
||||
assert.Equal(w.Code, http.StatusOK)
|
||||
assert.Regexp(`message successfully published to hello with sequence \d+`, w.Body.String())
|
||||
}
|
||||
|
||||
func BenchmarkMessageBusPut(b *testing.B) {
|
||||
mb := New(nil)
|
||||
topic := mb.NewTopic("foo")
|
||||
|
|
Načítá se…
Odkázat v novém úkolu