-
-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #461 - blocking mocks for responses and add v2.4.x…
… support Blocking mocks for responses and add v2.4.x support
- Loading branch information
Showing
24 changed files
with
929 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
language: go | ||
|
||
go: | ||
- 1.7.x | ||
- 1.8.x | ||
- 1.9.x | ||
- 1.10.x | ||
- 1.11.x | ||
- master | ||
- 1.12.x | ||
- 1.13.x | ||
|
||
cache: apt | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package rethinkdb | ||
|
||
import ( | ||
test "gopkg.in/check.v1" | ||
"gopkg.in/rethinkdb/rethinkdb-go.v5/internal/integration/tests" | ||
) | ||
|
||
type CursorSuite struct{} | ||
|
||
var _ = test.Suite(&CursorSuite{}) | ||
|
||
func (s *CursorSuite) TestCursor_One_Ok(c *test.C) { | ||
data := map[string]interface{}{ | ||
"A": 1, | ||
"B": true, | ||
} | ||
|
||
mock := NewMock() | ||
ch := make(chan []interface{}) | ||
mock.On(DB("test").Table("test")).Return(ch, nil) | ||
go func() { | ||
ch <- []interface{}{data} | ||
close(ch) | ||
}() | ||
res, err := DB("test").Table("test").Run(mock) | ||
c.Assert(err, test.IsNil) | ||
|
||
var response interface{} | ||
err = res.One(&response) | ||
|
||
c.Assert(err, test.IsNil) | ||
c.Assert(response, tests.JsonEquals, data) | ||
mock.AssertExpectations(c) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
package reql_tests | ||
|
||
import ( | ||
"github.com/stretchr/testify/suite" | ||
r "gopkg.in/rethinkdb/rethinkdb-go.v5" | ||
"testing" | ||
) | ||
|
||
// Test edge cases of bitwise operations | ||
func TestBitwiseSuite(t *testing.T) { | ||
suite.Run(t, new(BitwiseSuite)) | ||
} | ||
|
||
type BitwiseSuite struct { | ||
suite.Suite | ||
|
||
session *r.Session | ||
} | ||
|
||
func (suite *BitwiseSuite) SetupTest() { | ||
suite.T().Log("Setting up BitwiseSuite") | ||
|
||
session, err := r.Connect(r.ConnectOpts{ | ||
Address: url, | ||
}) | ||
suite.Require().NoError(err, "Error returned when connecting to server") | ||
suite.session = session | ||
} | ||
|
||
func (suite *BitwiseSuite) TearDownSuite() { | ||
suite.T().Log("Tearing down BitwiseSuite") | ||
|
||
if suite.session != nil { | ||
suite.session.Close() | ||
} | ||
} | ||
|
||
func (suite *BitwiseSuite) TestCases() { | ||
suite.T().Log("Running BitwiseSuite: Test edge cases of bitwise operations") | ||
|
||
runOpts := r.RunOpts{ | ||
GeometryFormat: "raw", | ||
GroupFormat: "map", | ||
} | ||
|
||
{ | ||
var q = r.BitAnd(3, 5) | ||
var expected_ = 3 & 5 | ||
|
||
suite.T().Logf("About to run line #1: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #1") | ||
} | ||
|
||
{ | ||
var q = r.Expr(3).BitAnd(5) | ||
var expected_ = 3 & 5 | ||
|
||
suite.T().Logf("About to run line #2: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #2") | ||
} | ||
|
||
{ | ||
var q = r.BitOr(3, 5) | ||
var expected_ = 3 | 5 | ||
|
||
suite.T().Logf("About to run line #3: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #3") | ||
} | ||
|
||
{ | ||
var q = r.Expr(3).BitOr(5) | ||
var expected_ = 3 | 5 | ||
|
||
suite.T().Logf("About to run line #4: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #4") | ||
} | ||
|
||
{ | ||
var q = r.BitXor(3, 5) | ||
var expected_ = 3 ^ 5 | ||
|
||
suite.T().Logf("About to run line #5: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #5") | ||
} | ||
|
||
{ | ||
var q = r.Expr(3).BitXor(5) | ||
var expected_ = 3 ^ 5 | ||
|
||
suite.T().Logf("About to run line #6: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #6") | ||
} | ||
|
||
{ | ||
var q = r.BitNot(3) | ||
var expected_ = ^3 | ||
|
||
suite.T().Logf("About to run line #7: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #7") | ||
} | ||
|
||
{ | ||
var q = r.Expr(3).BitNot() | ||
var expected_ = ^3 | ||
|
||
suite.T().Logf("About to run line #8: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #8") | ||
} | ||
|
||
{ | ||
var q = r.BitSal(3, 5) | ||
var expected_ = 3 << 5 | ||
|
||
suite.T().Logf("About to run line #9: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #9") | ||
} | ||
|
||
{ | ||
var q = r.Expr(3).BitSal(5) | ||
var expected_ = 3 << 5 | ||
|
||
suite.T().Logf("About to run line #10: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #10") | ||
} | ||
|
||
{ | ||
var q = r.BitSar(3, 5) | ||
var expected_ = 3 >> 5 | ||
|
||
suite.T().Logf("About to run line #11: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #11") | ||
} | ||
|
||
{ | ||
var q = r.Expr(3).BitSar(5) | ||
var expected_ = 3 >> 5 | ||
|
||
suite.T().Logf("About to run line #12: %v", q) | ||
|
||
runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) | ||
suite.T().Log("Finished running line #12") | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.