aboutsummaryrefslogtreecommitdiff
path: root/pkg/navitia_api_client/stops_test.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-09-15 21:29:12 +0200
committerJulien Dessaux2021-09-15 21:29:12 +0200
commite8b2b01e7c697435f3d20657cdef0ecd54b62d14 (patch)
tree4a4239c21fd2a9b0949abf7c74a3e88c91f6eb82 /pkg/navitia_api_client/stops_test.go
parentRewrote config tests for consistency (diff)
downloadtrains-e8b2b01e7c697435f3d20657cdef0ecd54b62d14.tar.gz
trains-e8b2b01e7c697435f3d20657cdef0ecd54b62d14.tar.bz2
trains-e8b2b01e7c697435f3d20657cdef0ecd54b62d14.zip
Rewrote navitia_api_client tests for consistency
Diffstat (limited to 'pkg/navitia_api_client/stops_test.go')
-rw-r--r--pkg/navitia_api_client/stops_test.go24
1 files changed, 11 insertions, 13 deletions
diff --git a/pkg/navitia_api_client/stops_test.go b/pkg/navitia_api_client/stops_test.go
index c3a91f2..b04946f 100644
--- a/pkg/navitia_api_client/stops_test.go
+++ b/pkg/navitia_api_client/stops_test.go
@@ -3,11 +3,9 @@ package navitia_api_client
import (
"net/http"
"net/http/httptest"
- "reflect"
"testing"
"git.adyxax.org/adyxax/trains/pkg/model"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -17,10 +15,10 @@ func TestGetStops(t *testing.T) {
name string
inputNewCLient string
expected []model.Stop
- expectedError interface{}
+ expectedError error
}{
- {"invalid characters in token should fail", "}", nil, &HttpClientError{}},
- {"unreachable server should fail", "https://", nil, &HttpClientError{}},
+ {"invalid characters in token should fail", "}", nil, HttpClientError{}},
+ {"unreachable server should fail", "https://", nil, HttpClientError{}},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
@@ -28,11 +26,11 @@ func TestGetStops(t *testing.T) {
valid, err := client.GetStops()
if tc.expectedError != nil {
require.Error(t, err)
- assert.Equalf(t, reflect.TypeOf(err), reflect.TypeOf(tc.expectedError), "Invalid error type. Got %s but expected %s", reflect.TypeOf(err), reflect.TypeOf(tc.expectedError))
- assert.Equal(t, tc.expected, valid)
+ requireErrorTypeMatch(t, err, tc.expectedError)
+ require.Equal(t, tc.expected, valid)
} else {
require.NoError(t, err)
- assert.Equal(t, tc.expected, valid)
+ require.Equal(t, tc.expected, valid)
}
})
}
@@ -41,9 +39,9 @@ func TestGetStops(t *testing.T) {
name string
inputFilename string
expected []model.Stop
- expectedError interface{}
+ expectedError error
}{
- {"invalid json should fail", "test_data/invalid.json", nil, &JsonDecodeError{}},
+ {"invalid json should fail", "test_data/invalid.json", nil, JsonDecodeError{}},
}
for _, tc := range testCasesFilename {
t.Run(tc.name, func(t *testing.T) {
@@ -52,11 +50,11 @@ func TestGetStops(t *testing.T) {
valid, err := client.GetStops()
if tc.expectedError != nil {
require.Error(t, err)
- assert.Equalf(t, reflect.TypeOf(err), reflect.TypeOf(tc.expectedError), "Invalid error type. Got %s but expected %s", reflect.TypeOf(err), reflect.TypeOf(tc.expectedError))
- assert.Equal(t, tc.expected, valid)
+ requireErrorTypeMatch(t, err, tc.expectedError)
+ require.Equal(t, tc.expected, valid)
} else {
require.NoError(t, err)
- assert.Equal(t, tc.expected, valid)
+ require.Equal(t, tc.expected, valid)
}
})
}