Skip to content

Commit 56c5347

Browse files
committed
FIX issues#49. Find and FindOne returns nil objects
1 parent 335d899 commit 56c5347

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

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/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)