Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerinthenight committed Oct 4, 2017
1 parent bbb8f37 commit 5676267
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pkg/notification/httpnotify_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
package notification

import "testing"
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
)

func TestNewSimpleHttpNotify(t *testing.T) {
n := NewSimpleHttpNotify("test")
if n == nil {
t.Fatal("should not be nil")
}
}

func TestNotify(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
body, _ := ioutil.ReadAll(r.Body)
if string(body) != "test" {
t.Fatal("should be test")
}
}))

defer ts.Close()
n := NewSimpleHttpNotify(ts.URL)
n.Notify([]byte("test"))

}

0 comments on commit 5676267

Please sign in to comment.