globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 230 forks source link

[#179] Array Filters Method Implemented With Tests and Documentation #208

Closed crhntr closed 6 years ago

crhntr commented 6 years ago

I was not able to run the harnes/setup.sh on my machine for some reason. However, I wrote some tests using the testing package that passed and then rewrote parts of the tests using gopkg.in/check.v1.

Please verify the tests pass on a machine that has "check" working.

The test data is based on the example in the MongoDB arrayFilter documentation.

domodwyer commented 6 years ago

Hey @crhntr

Thanks for taking the time to put this together, it's really appreciated!

We have a helper for the tests that should help, the check you've got at the moment doesn't skip properly on <3.6 - try this:

if s.versionAtLeast(3, 6) {
    c.Skip("requires 3.6+")
}

Sorry about running the tests - I know it's a nightmare and doesn't work properly on OS X, it never really has I think (including the original mgo) - I've avoiding messing with it because it works on travis, but I know it's frustrating - sorry!

Other than that, looks great, we'll happily accept this PR :) Thanks again!

Dom

crhntr commented 6 years ago

@domodwyer Good evening, :) I'm sorry it took so many tries to get the tests mostly passing. Unfortunately I am still getting an error and am not sure why. It seams like the Go 1.10 with Mongo 3.0.15 is failing on some seemingly unrelated test. I branched from origin/development.

This failed: https://travis-ci.org/globalsign/mgo/builds/401126479

The previous development test passed: https://travis-ci.org/globalsign/mgo/builds/400001106

Not sure why... here is the output with FAIL sections.

crhntr@Christophers-MacBook-Air ~/tmp  $ cat buildlog.txt | grep -C 10 FAIL
PASS: session_test.go:70: S.TestPing    0.001s
SKIP: session_test.go:90: S.TestPingSsl (this test requires the usage of the system provided certificates)
PASS: session_test.go:4827: S.TestPipeAll   0.050s
SKIP: session_test.go:4898: S.TestPipeCollation (collations being released with 3.4)
PASS: session_test.go:4877: S.TestPipeExplain   0.049s
PASS: session_test.go:4791: S.TestPipeIter  0.051s
PASS: session_test.go:4852: S.TestPipeOne   0.079s
SKIP: cluster_test.go:1615: S.TestPoolLimitMany (-fast)

----------------------------------------------------------------------
FAIL: cluster_test.go:1570: S.TestPoolLimitSimple

[LOG] 15.26312 Resetting stats
[LOG] 15.26326 Cluster 0xc423c7e780 acquired (refs=2)
[LOG] 15.26327 New session 0xc4201db500 on cluster 0xc423c7e780
[LOG] 15.26328 Session 0xc4201db500: setting mode 0 with refresh=true (master=0x0, slave=0x0)
[LOG] 15.26329 Cluster 0xc423c7e780 released (refs=1)
[LOG] 15.26329 Cluster has 0 known masters and 0 known slaves.
[LOG] 15.26329 Waiting for servers to synchronize...
[LOG] 15.26330 SYNC Cluster 0xc423c7e780 is starting a sync loop iteration.
[LOG] 15.26331 SYNC Starting full topology synchronization...
--
--
PASS: session_test.go:686: S.TestUpdateId   0.058s
PASS: session_test.go:714: S.TestUpdateNil  0.063s
SKIP: session_test.go:744: S.TestUpdateWithArrayFiltersMulti (requires 3.6+)
SKIP: session_test.go:787: S.TestUpdateWithArrayFiltersSingle (requires 3.6+)
PASS: session_test.go:830: S.TestUpsert 0.058s
PASS: session_test.go:893: S.TestUpsertId   0.061s
PASS: session_test.go:5185: S.TestVersionAtLeast    0.000s
SKIP: session_test.go:1593: S.TestView (depends on mongodb 3.4+)
SKIP: session_test.go:1685: S.TestViewWithCollation (Fails because of a MongoDB bug as of version 3.4.9, cf https://jira.mongodb.org/browse/SERVER-31049)
PASS: session_test.go:4683: S.TestZeroTimeRoundtrip 0.062s
OOPS: 227 passed, 63 skipped, 1 FAILED
--- FAIL: TestAll (101.39s)
FAIL
exit status 1
--
exit status 1
FAIL    github.com/globalsign/mgo   101.441s

travis_time:end:0104eb18:start=1530932127661792121,finish=1530932230043331584,duration=102381539463
[0K
[31;1mThe command "go test -check.v -fast" exited with 1.[0m
travis_time:start:24a364ed
[0K$ (cd txn && go test -check.v)
PASS: dockey_test.go:198: DocKeySuite.TestSort  0.000s
PASS: tarjan_test.go:25: TarjanSuite.TestExample    0.000s
PASS: txn_test.go:369: S.TestAssertNestedOr 0.010s
PASS: txn_test.go:417: S.TestChangeLog  0.014s
domodwyer commented 6 years ago

Hi @crhntr

Don't worry, flakey tests - the PR looks great, thanks very much!

Dom

domodwyer commented 6 years ago

Thanks very much @crhntr - it's really appreciated!