@@ -12,11 +12,6 @@ import (
1212"time"
1313)
1414
15- func init () {
16- // set timezone as UTC for bson/json time marshalling
17- time .Local = time .UTC
18- }
19-
2015// This test is composed by several subtests and uses httptest.ResponseRecorder type to record http response.
2116// These are NOT end-to-end tests as we are directly calling the controller methods we want to test.
2217func TestTaskControllerGet (t * testing.T ) {
@@ -48,7 +43,11 @@ func TestTaskControllerGet(t *testing.T) {
4843t .Errorf ("Wrong response code. Got %d instead of %d." , res .Code , http .StatusOK )
4944}
5045
51- if dao .MockedTask != taskOut [0 ] {
46+ if len (taskOut ) < 1 {
47+ t .Fatal ("Wrong result size < 1" )
48+ }
49+
50+ if ! dao .MockedTask .Equal (taskOut [0 ]) {
5251t .Errorf ("Expected different from %v output %v" , dao .MockedTask , taskOut [0 ])
5352}
5453})
@@ -78,7 +77,7 @@ func TestTaskControllerGet(t *testing.T) {
7877t .Errorf ("Wrong response code. Got %d instead of %d." , res .Code , http .StatusOK )
7978}
8079
81- if dao .MockedTask != taskOut {
80+ if ! dao .MockedTask . Equal ( taskOut ) {
8281t .Errorf ("Expected different from %v output %v" , dao .MockedTask , taskOut )
8382}
8483})
@@ -116,7 +115,7 @@ func TestTaskControllerGet(t *testing.T) {
116115}
117116
118117task .ID = taskOut .ID
119- if task != taskOut {
118+ if ! task . Equal ( taskOut ) {
120119t .Errorf ("Expected different from %v output %v" , task , taskOut )
121120}
122121})
@@ -167,7 +166,7 @@ func TestTaskControllerGetServer(t *testing.T) {
167166}
168167
169168task .ID = taskTest .ID
170- if task != taskTest {
169+ if ! task . Equal ( taskTest ) {
171170t .Errorf ("Expected different from %v output %v" , task , taskTest )
172171}
173172})
@@ -190,11 +189,11 @@ func TestTaskControllerGetServer(t *testing.T) {
190189}
191190
192191if len (resTask ) < 1 {
193- t .Errorf ( "Expected length different from %v output 1" , len ( resTask ) )
194- } else {
195- if resTask [ 0 ] != taskTest {
196- t . Errorf ( "Expected different from %v output %v" , resTask [0 ], taskTest )
197- }
192+ t .Fatal ( "Wrong result size < 1" )
193+ }
194+
195+ if ! resTask [0 ]. Equal ( taskTest ) {
196+ t . Errorf ( "Expected different from %v output %v" , resTask [ 0 ], taskTest )
198197}
199198})
200199
@@ -215,7 +214,7 @@ func TestTaskControllerGetServer(t *testing.T) {
215214t .Errorf ("Wrong response code. Got %d instead of %d." , res .StatusCode , http .StatusOK )
216215}
217216
218- if resTask != taskTest {
217+ if ! resTask . Equal ( taskTest ) {
219218t .Errorf ("Expected different from %v output %v" , resTask , taskTest )
220219}
221220})
@@ -229,7 +228,7 @@ func BenchmarkTaskControllerGet(b *testing.B) {
229228handler := NewTaskController (daoMock )
230229
231230// build a request
232- req , err := http .NewRequest ("GET" , "localhost/tasks" , nil )
231+ req , err := http .NewRequest (http . MethodGet , "localhost/tasks" , nil )
233232if err != nil {
234233b .Fatal (err )
235234}
0 commit comments