-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_test.go
More file actions
40 lines (34 loc) · 1.01 KB
/
setup_test.go
File metadata and controls
40 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"bytes"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/supu-io/messages"
. "github.com/smartystreets/goconvey/convey"
)
func issueTrackerSetup(org string, repo string) *httptest.ResponseRecorder {
m := setupRouter()
var jsonStr = []byte("")
request, _ := http.NewRequest("POST", "/setup?org="+org+"&repo="+repo, bytes.NewBuffer(jsonStr))
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
response := httptest.NewRecorder()
m.ServeHTTP(response, request)
return response
}
func TestSetup(t *testing.T) {
setup()
Convey("When I setup a repo", t, func() {
source = "workflows/test/default.json"
subscribe("issue-tracker.setup", "")
response := issueTrackerSetup("org", "repo")
res := messages.Setup{}
json.Unmarshal([]byte(response.Body.String()), &res)
Convey("Then it should return a valid message", func() {
So(res.Org, ShouldEqual, "org")
So(res.Repo, ShouldEqual, "repo")
So(len(res.States), ShouldEqual, 2)
})
})
}