Skip to content

Commit 71e9e10

Browse files
authored
Merge pull request #57 from dpordomingo/kallaxTestsFixes
Kallax integration tests fixes
2 parents 335d899 + 7ab7453 commit 71e9e10

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

generator/templates/resultset.tgo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func New{{.ResultSetName}}(rs kallax.ResultSet) *{{.ResultSetName}} {
1919
func (rs *{{.ResultSetName}}) Next() bool {
2020
if !rs.ResultSet.Next() {
2121
rs.lastErr = rs.ResultSet.Close()
22+
rs.last = nil
2223
return false
2324
}
2425

tests/common_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ func (s *BaseTestSuite) resultOrError(res interface{}, err error) bool {
9595
}
9696

9797
if err == nil && res == nil {
98-
s.Fail(
99-
`FindOne should return an error or a document, but nothing was returned
100-
TODO: https://github.com/src-d/go-kallax/issues/49`,
101-
)
98+
s.Fail("FindOne should return an error or a document, but nothing was returned")
10299
return false
103100
}
104101

tests/kallax.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ func NewCarResultSet(rs kallax.ResultSet) *CarResultSet {
356356
func (rs *CarResultSet) Next() bool {
357357
if !rs.ResultSet.Next() {
358358
rs.lastErr = rs.ResultSet.Close()
359+
rs.last = nil
359360
return false
360361
}
361362

@@ -735,6 +736,7 @@ func NewEventsFixtureResultSet(rs kallax.ResultSet) *EventsFixtureResultSet {
735736
func (rs *EventsFixtureResultSet) Next() bool {
736737
if !rs.ResultSet.Next() {
737738
rs.lastErr = rs.ResultSet.Close()
739+
rs.last = nil
738740
return false
739741
}
740742

@@ -1106,6 +1108,7 @@ func NewEventsSaveFixtureResultSet(rs kallax.ResultSet) *EventsSaveFixtureResult
11061108
func (rs *EventsSaveFixtureResultSet) Next() bool {
11071109
if !rs.ResultSet.Next() {
11081110
rs.lastErr = rs.ResultSet.Close()
1111+
rs.last = nil
11091112
return false
11101113
}
11111114

@@ -1465,6 +1468,7 @@ func NewMultiKeySortFixtureResultSet(rs kallax.ResultSet) *MultiKeySortFixtureRe
14651468
func (rs *MultiKeySortFixtureResultSet) Next() bool {
14661469
if !rs.ResultSet.Next() {
14671470
rs.lastErr = rs.ResultSet.Close()
1471+
rs.last = nil
14681472
return false
14691473
}
14701474

@@ -1987,6 +1991,7 @@ func NewPersonResultSet(rs kallax.ResultSet) *PersonResultSet {
19871991
func (rs *PersonResultSet) Next() bool {
19881992
if !rs.ResultSet.Next() {
19891993
rs.lastErr = rs.ResultSet.Close()
1994+
rs.last = nil
19901995
return false
19911996
}
19921997

@@ -2419,6 +2424,7 @@ func NewPetResultSet(rs kallax.ResultSet) *PetResultSet {
24192424
func (rs *PetResultSet) Next() bool {
24202425
if !rs.ResultSet.Next() {
24212426
rs.lastErr = rs.ResultSet.Close()
2427+
rs.last = nil
24222428
return false
24232429
}
24242430

@@ -2770,6 +2776,7 @@ func NewQueryFixtureResultSet(rs kallax.ResultSet) *QueryFixtureResultSet {
27702776
func (rs *QueryFixtureResultSet) Next() bool {
27712777
if !rs.ResultSet.Next() {
27722778
rs.lastErr = rs.ResultSet.Close()
2779+
rs.last = nil
27732780
return false
27742781
}
27752782

@@ -3121,6 +3128,7 @@ func NewResultSetFixtureResultSet(rs kallax.ResultSet) *ResultSetFixtureResultSe
31213128
func (rs *ResultSetFixtureResultSet) Next() bool {
31223129
if !rs.ResultSet.Next() {
31233130
rs.lastErr = rs.ResultSet.Close()
3131+
rs.last = nil
31243132
return false
31253133
}
31263134

@@ -3582,6 +3590,7 @@ func NewSchemaFixtureResultSet(rs kallax.ResultSet) *SchemaFixtureResultSet {
35823590
func (rs *SchemaFixtureResultSet) Next() bool {
35833591
if !rs.ResultSet.Next() {
35843592
rs.lastErr = rs.ResultSet.Close()
3593+
rs.last = nil
35853594
return false
35863595
}
35873596

@@ -3933,6 +3942,7 @@ func NewStoreFixtureResultSet(rs kallax.ResultSet) *StoreFixtureResultSet {
39333942
func (rs *StoreFixtureResultSet) Next() bool {
39343943
if !rs.ResultSet.Next() {
39353944
rs.lastErr = rs.ResultSet.Close()
3945+
rs.last = nil
39363946
return false
39373947
}
39383948

@@ -4284,6 +4294,7 @@ func NewStoreWithConstructFixtureResultSet(rs kallax.ResultSet) *StoreWithConstr
42844294
func (rs *StoreWithConstructFixtureResultSet) Next() bool {
42854295
if !rs.ResultSet.Next() {
42864296
rs.lastErr = rs.ResultSet.Close()
4297+
rs.last = nil
42874298
return false
42884299
}
42894300

@@ -4639,6 +4650,7 @@ func NewStoreWithNewFixtureResultSet(rs kallax.ResultSet) *StoreWithNewFixtureRe
46394650
func (rs *StoreWithNewFixtureResultSet) Next() bool {
46404651
if !rs.ResultSet.Next() {
46414652
rs.lastErr = rs.ResultSet.Close()
4653+
rs.last = nil
46424654
return false
46434655
}
46444656

tests/query_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ func (s *QuerySuite) TestQuery() {
2929

3030
query := NewQueryFixtureQuery()
3131
query.Where(kallax.Eq(Schema.QueryFixture.ID, doc.ID))
32+
3233
s.NotPanics(func() {
3334
s.Equal("bar", store.MustFindOne(query).Foo)
34-
}, "TODO: https://github.com/src-d/go-kallax/issues/49")
35+
})
3536

3637
notID := kallax.NewID()
3738
queryErr := NewQueryFixtureQuery()

tests/resultset_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ func (s *ResulsetSuite) TestResultSetForEachError() {
136136
})
137137
}
138138

139-
// TODO: https://github.com/src-d/go-kallax/issues/49
140139
func (s *ResulsetSuite) TestForEachAndCount() {
141140
store := NewResultSetFixtureStore(s.db)
142141

@@ -151,7 +150,7 @@ func (s *ResulsetSuite) TestForEachAndCount() {
151150
manualCount := 0
152151
rs.ForEach(func(doc *ResultSetFixture) error {
153152
manualCount++
154-
s.NotNil(doc, "TODO: https://github.com/src-d/go-kallax/issues/49")
153+
s.NotNil(doc)
155154
return nil
156155
})
157156
s.Equal(2, manualCount)

tests/store_test.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ func (s *StoreSuite) TestStoreInsertUpdateMustFind() {
8686
s.Nil(err)
8787
s.NotPanics(func() {
8888
s.Equal("foo", store.MustFindOne(NewStoreWithConstructFixtureQuery()).Foo)
89-
}, "TODO: https://github.com/src-d/go-kallax/issues/49")
89+
})
9090

9191
doc.Foo = "bar"
9292
updatedRows, err := store.Update(doc)
9393
s.Nil(err)
9494
s.True(updatedRows > 0)
9595
s.NotPanics(func() {
9696
s.Equal("bar", store.MustFindOne(NewStoreWithConstructFixtureQuery()).Foo)
97-
}, "TODO: https://github.com/src-d/go-kallax/issues/49")
97+
})
9898
}
9999

100100
func (s *StoreSuite) TestStoreSave() {
@@ -107,15 +107,15 @@ func (s *StoreSuite) TestStoreSave() {
107107
s.True(doc.IsPersisted())
108108
s.NotPanics(func() {
109109
s.Equal("foo", store.MustFindOne(NewStoreWithConstructFixtureQuery()).Foo)
110-
}, "TODO: https://github.com/src-d/go-kallax/issues/49")
110+
})
111111

112112
doc.Foo = "bar"
113113
updated, err = store.Save(doc)
114114
s.Nil(err)
115115
s.True(updated)
116116
s.NotPanics(func() {
117117
s.Equal("bar", store.MustFindOne(NewStoreWithConstructFixtureQuery()).Foo)
118-
}, "TODO: https://github.com/src-d/go-kallax/issues/49")
118+
})
119119
}
120120

121121
func (s *StoreSuite) TestMultiKeySort() {
@@ -169,16 +169,13 @@ func (s *StoreSuite) TestMultiKeySort() {
169169
s.Len(documents, 4)
170170
success := true
171171
for _, doc := range documents {
172-
if !s.NotNil(doc, "TODO: https://github.com/src-d/go-kallax/issues/49") {
172+
if !s.NotNil(doc) {
173173
success = false
174174
}
175175
}
176176

177177
if !success {
178-
s.Fail(
179-
`Testcase aborted. All retrieved Documents should be not-nil
180-
TODO: https://github.com/src-d/go-kallax/issues/49`,
181-
)
178+
s.Fail("Testcase aborted. All retrieved Documents should be not-nil")
182179
return
183180
}
184181

@@ -188,7 +185,6 @@ func (s *StoreSuite) TestMultiKeySort() {
188185
s.Equal("2001-2012", documents[3].Name)
189186
}
190187

191-
// TODO: https://github.com/src-d/go-kallax/issues/49
192188
func (s *StoreSuite) TestFindOne() {
193189
store := NewStoreWithConstructFixtureStore(s.db)
194190

@@ -198,7 +194,7 @@ func (s *StoreSuite) TestFindOne() {
198194
query := NewStoreWithConstructFixtureQuery()
199195
docFound, err := store.FindOne(query)
200196
s.resultOrError(docFound, err)
201-
if s.NotNil(docFound, "TODO: https://github.com/src-d/go-kallax/issues/49") {
197+
if s.NotNil(docFound) {
202198
s.Equal(docInserted.Foo, docFound.Foo)
203199
}
204200
}

0 commit comments

Comments
 (0)