-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
flowerinthenight
committed
Oct 4, 2017
1 parent
bbb8f37
commit 5676267
Showing
1 changed file
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | ||
|
||
} |