-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_test.go
63 lines (56 loc) · 1.8 KB
/
init_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
//
// ______ _ _ _ __ _ _ ____ ___
// | ____| | | | | | |/ _| | | | | |___ \ / _ \
// | |__ __ _| |_| |__ __ _| | |_ __ _| |_| |__ __) | | | |
// | __/ _` | __| '_ \ / _` | | _/ _` | __| '_ \ |__ <| | | |
// | | | (_| | |_| | | | (_| | | || (_| | |_| | | |___) | |_| |
// |_| \__,_|\__|_| |_|\__,_|_|_| \__,_|\__|_| |_|____/ \___/
//
// Written by Fathalfath30.
// Email : fathalfath30@gmail.com
// Follow me on:
// Github : https://github.com/fathalfath30
// Gitlab : https://gitlab.com/Fathalfath30
//
*/
package goquest_test
import (
"github.com/fathalfath30/goquest"
"github.com/fathalfath30/goquest/testdata"
"net/http"
)
func (ts *GoQuesTestSuite) Test_InitialSetup() {
ts.Run("it should return default value", func() {
gq, err := goquest.New(testdata.ValidSampleBaseUrl, nil)
ts.Require().NotNil(gq)
ts.Require().IsType(&goquest.GoQuest{}, gq)
ts.Require().Nil(err)
})
ts.Run("it can set default header from client", func() {
gq, err := goquest.New(testdata.ValidSampleBaseUrl, &goquest.Config{
Client: &http.Client{},
Header: &http.Header{},
Transport: &http.Transport{},
})
ts.Require().NotNil(gq)
ts.Require().IsType(&goquest.GoQuest{}, gq)
ts.Require().Nil(err)
})
ts.Run("it can set baseUrl", func() {
gq, err := goquest.New(testdata.ValidSampleBaseUrl, &goquest.Config{
BaseUrl: testdata.ValidSampleBaseUrl,
})
ts.Require().NotNil(gq)
ts.Require().IsType(&goquest.GoQuest{}, gq)
ts.Require().Nil(err)
})
}
func (ts *GoQuesTestSuite) Test_InitialSetup_MustHandleError() {
ts.Run("it should handle error when failed parse base url", func() {
gq, err := goquest.New("-://localhost:we", nil)
ts.Require().Nil(gq)
ts.Require().Error(err)
ts.Require().Contains(err.Error(), "failed to parse base url")
})
}