Added script tests specific to dolt

This commit is contained in:
Zach Musgrave
2021-10-11 12:49:29 -07:00
parent 8a5f3f54be
commit b7770f8ea2
2 changed files with 60 additions and 0 deletions

View File

@@ -334,6 +334,13 @@ func TestTransactions(t *testing.T) {
}
}
func TestDoltScripts(t *testing.T) {
harness := newDoltHarness(t)
for _, script := range DoltScripts {
enginetest.TestScript(t, harness, script)
}
}
// TestSingleTransactionScript is a convenience method for debugging a single transaction test. Unskip and set to the
// desired test.
func TestSingleTransactionScript(t *testing.T) {

View File

@@ -0,0 +1,53 @@
// Copyright 2021 Dolthub, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package enginetest
import (
"github.com/dolthub/go-mysql-server/enginetest"
"github.com/dolthub/go-mysql-server/sql"
)
// DoltScripts are script tests specific to Dolt (not the engine in general), e.g. by involving Dolt functions. Break
// this slice into others with good names as it grows.
var DoltScripts = []enginetest.ScriptTest {
{
Name: "test as of indexed join (https://github.com/dolthub/dolt/issues/2189)",
SetUpScript: []string{
"create table a (pk int primary key, c1 int)",
"insert into a values (1,1), (2,2), (3,3)",
"select DOLT_COMMIT('-a', '-m', 'first commit')",
"insert into a values (4,4), (5,5), (6,6)",
"select DOLT_COMMIT('-a', '-m', 'second commit')",
"set @second_commit = (select commit_hash from dolt_log order by date desc limit 1)",
"set @first_commit = (select commit_hash from dolt_log order by date desc limit 1,1)",
},
Assertions: []enginetest.ScriptTestAssertion{
{
Query: "select a1.* from a as of @second_commit a1 " +
"left join a as of @first_commit a2 on a1.pk = a2.pk where a2.pk is null order by 1",
Expected: []sql.Row{
{4, 4},
{5, 5},
{6, 6},
},
},
{
Query: "select a1.* from a as of @second_commit a1 " +
"left join a as of @second_commit a2 on a1.pk = a2.pk where a2.pk is null order by 1",
Expected: []sql.Row{},
},
},
},
}