Skip to content

test: fix compatibility with Tarantool master #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
### Fixed

- crud tests with Tarantool 3.0 (#293)
- SQL tests with Tarantool 3.0 (#295)

## [1.11.0] - 2023-05-18

Expand Down
11 changes: 9 additions & 2 deletions settings/tarantool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,14 @@ func TestSQLReverseUnorderedSelectsSetting(t *testing.T) {
require.Equal(t, []interface{}{[]interface{}{"sql_reverse_unordered_selects", false}}, resp.Data)

// Select multiple records.
resp, err = conn.Execute("SELECT * FROM data;", []interface{}{})
query := "SELECT * FROM seqscan data;"
if isSeqScanOld, err := test_helpers.IsTarantoolVersionLess(3, 0, 0); err != nil {
t.Fatal("Could not check the Tarantool version")
} else if isSeqScanOld {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, Seqscan was introduced in 2.11.0-rc1 (but it's not required by default), so you may use this condition too.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a good idea to test the default, which is 'old' for 2.11 and 'new` (with seqscan key word) in 3.0 and up.

query = "SELECT * FROM data;"
}

resp, err = conn.Execute(query, []interface{}{})
require.Nil(t, err)
require.NotNil(t, resp)
require.EqualValues(t, []interface{}{"1"}, resp.Data[0])
Expand All @@ -500,7 +507,7 @@ func TestSQLReverseUnorderedSelectsSetting(t *testing.T) {
require.Equal(t, []interface{}{[]interface{}{"sql_reverse_unordered_selects", true}}, resp.Data)

// Select multiple records.
resp, err = conn.Execute("SELECT * FROM data;", []interface{}{})
resp, err = conn.Execute(query, []interface{}{})
require.Nil(t, err)
require.NotNil(t, resp)
require.EqualValues(t, []interface{}{"2"}, resp.Data[0])
Expand Down
12 changes: 10 additions & 2 deletions tarantool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,8 @@ const (
selectPosQuery = "SELECT id, name FROM SQL_SPACE WHERE id=? AND name=?;"
updateQuery = "UPDATE SQL_SPACE SET name=? WHERE id=?;"
enableFullMetaDataQuery = "SET SESSION \"sql_full_metadata\" = true;"
selectSpanDifQuery = "SELECT id||id, name, id FROM SQL_SPACE WHERE name=?;"
selectSpanDifQueryNew = "SELECT id||id, name, id FROM seqscan SQL_SPACE WHERE name=?;"
selectSpanDifQueryOld = "SELECT id||id, name, id FROM SQL_SPACE WHERE name=?;"
alterTableQuery = "ALTER TABLE SQL_SPACE RENAME TO SQL_SPACE2;"
insertIncrQuery = "INSERT INTO SQL_SPACE2 VALUES (?, ?);"
deleteQuery = "DELETE FROM SQL_SPACE2 WHERE name=?;"
Expand All @@ -1353,6 +1354,13 @@ func TestSQL(t *testing.T) {
Resp Response
}

selectSpanDifQuery := selectSpanDifQueryNew
if isSeqScanOld, err := test_helpers.IsTarantoolVersionLess(3, 0, 0); err != nil {
t.Fatal("Could not check the Tarantool version")
} else if isSeqScanOld {
selectSpanDifQuery = selectSpanDifQueryOld
}

testCases := []testCase{
{
createTableQuery,
Expand Down Expand Up @@ -1498,7 +1506,7 @@ func TestSQL(t *testing.T) {

for i, test := range testCases {
resp, err := conn.Execute(test.Query, test.Args)
assert.NoError(t, err, "Failed to Execute, Query number: %d", i)
assert.NoError(t, err, "Failed to Execute, query: %s", test.Query)
assert.NotNil(t, resp, "Response is nil after Execute\nQuery number: %d", i)
for j := range resp.Data {
assert.Equal(t, resp.Data[j], test.Resp.Data[j], "Response data is wrong")
Expand Down