forked from vfarcic/go-demo-6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functional_test.go
49 lines (39 loc) · 1.04 KB
/
functional_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
45
46
47
48
49
package main
import (
"fmt"
"net/http"
"os"
"testing"
"github.com/stretchr/testify/suite"
)
type FunctionalTestSuite struct {
suite.Suite
hostIp string
servicePath string
}
func TestFunctionalTestSuite(t *testing.T) {
s := new(FunctionalTestSuite)
s.hostIp = os.Getenv("ADDRESS")
s.servicePath = "/demo"
if len(os.Getenv("SERVICE_PATH")) > 0 {
s.servicePath = os.Getenv("SERVICE_PATH")
}
suite.Run(t, s)
}
func (s *FunctionalTestSuite) SetupTest() {
}
// Functional
func (s FunctionalTestSuite) Test_Hello_ReturnsStatus200() {
address := fmt.Sprintf("http://%s%s/hello", s.hostIp, s.servicePath)
logPrintf("Sending a request to %s\n", address)
resp, err := http.Get(address)
s.NoError(err)
s.Equal(200, resp.StatusCode, "ADDR: ", address)
}
func (s FunctionalTestSuite) Test_Person_ReturnsStatus200() {
address := fmt.Sprintf("http://%s%s/person", s.hostIp, s.servicePath)
logPrintf("Sending a request to %s\n", address)
resp, err := http.Get(address)
s.NoError(err)
s.Equal(200, resp.StatusCode, "ADDR: %s", address)
}