Added POST /hello test

This commit is contained in:
James Mills 2018-05-10 00:26:51 -07:00
rodič 03e0fb07c7
revize b3fba70b13
V databázi nebyl nalezen žádný známý klíč pro tento podpis
ID GPG klíče: AC4C014F1440EBD6

Zobrazit soubor

@ -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")