-
Notifications
You must be signed in to change notification settings - Fork 12
/
jar_test.go
44 lines (36 loc) · 991 Bytes
/
jar_test.go
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
41
42
43
44
package aqua
import (
"fmt"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
type jarService struct {
RestService
echo GetApi
echo2 GetApi
}
func (u *jarService) Echo(j Jar) string {
j.LoadVars()
return j.QueryVars["abc"]
}
func (u *jarService) Echo2(j Jar) string {
return j.QueryVars["def"]
}
func TestJarForHttpGETMethod(t *testing.T) {
s := NewRestServer()
s.AddService(&jarService{})
s.Port = getUniquePortForTestCase()
s.RunAsync()
Convey("Given a RestServer and a service", t, func() {
Convey("Echo service should return Query String assigned to key: abc", func() {
url := fmt.Sprintf("http://localhost:%d/jar/echo?abc=whatsUp", s.Port)
_, _, content := getUrl(url, nil)
So(content, ShouldEqual, "whatsUp")
})
Convey("Echo2 service should fail since LoadVars is not invoked", func() {
url := fmt.Sprintf("http://localhost:%d/jar/echo2?def=hello", s.Port)
_, _, content := getUrl(url, nil)
So(content, ShouldEqual, "")
})
})
}