-
Notifications
You must be signed in to change notification settings - Fork 0
/
responses_test.go
40 lines (33 loc) · 1.2 KB
/
responses_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
package rajaongkir_go
import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"testing"
)
type ResponsesTestSuite struct {
suite.Suite
}
func (suite *ResponsesTestSuite) TestProvinceSuccess() {
respProvince := ResponseProvinces{}
_ = respProvince.Unmarshal([]byte(TestResponseProvinceSuccess))
assert.Equal(suite.T(), "Bali", respProvince.Results[0].Province)
assert.Equal(suite.T(), "1", respProvince.Results[0].ID)
assert.Nil(suite.T(), respProvince.StatusValid())
}
func (suite *ResponsesTestSuite) TestCitySuccess() {
respCity := ResponseCities{}
_ = respCity.Unmarshal([]byte(TestResponseCitySuccess))
assert.Equal(suite.T(), "Nanggroe Aceh Darussalam (NAD)", respCity.Results[0].Province)
assert.Equal(suite.T(), "1", respCity.Results[0].ID)
assert.Nil(suite.T(), respCity.StatusValid())
}
func (suite *ResponsesTestSuite) TestCostSuccess() {
respCost := ResponseCost{}
_ = respCost.Unmarshal([]byte(TestResponseCostSuccess))
assert.Equal(suite.T(), "jne", respCost.Results[0].Code)
assert.Equal(suite.T(), 1, len(respCost.Results[0].Costs))
assert.Nil(suite.T(), respCost.StatusValid())
}
func TestResponsesTestSuite(t *testing.T) {
suite.Run(t, new(ResponsesTestSuite))
}