super schema tests

This commit is contained in:
Andy Arthur
2020-03-31 16:35:21 -07:00
parent 7a9a3c3faa
commit 309421adf1
5 changed files with 22 additions and 20 deletions
@@ -17,6 +17,7 @@ package schema
import (
"errors"
"fmt"
"github.com/liquidata-inc/dolt/go/libraries/utils/set"
)
@@ -15,9 +15,10 @@
package schema
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
"github.com/liquidata-inc/dolt/go/libraries/doltcore/schema/typeinfo"
"github.com/liquidata-inc/dolt/go/store/types"
@@ -71,20 +72,20 @@ type SuperSchemaTest struct {
var SuperSchemaTests = []SuperSchemaTest{
{
Name: "SuperSchema of one Schema",
Schemas: []Schema{ sch1 },
Name: "SuperSchema of one Schema",
Schemas: []Schema{sch1},
ExpectedSuperSchema: SuperSchema{
allCols: mustColColl([]Column{
strCol("", 1, true),
strCol("", 2, false),
strCol("", 3, false),
}),
tagNames: map[uint64][]string{ 1: {"a"}, 2: {"b"}, 3: {"c"}}},
tagNames: map[uint64][]string{1: {"a"}, 2: {"b"}, 3: {"c"}}},
ExpectedGeneratedSchema: sch1,
},
{
Name: "SuperSchema of multiple Schemas",
Schemas: []Schema{ sch1, sch2, sch3 },
Name: "SuperSchema of multiple Schemas",
Schemas: []Schema{sch1, sch2, sch3},
ExpectedSuperSchema: SuperSchema{
allCols: mustColColl([]Column{
strCol("", 1, true),
@@ -93,7 +94,7 @@ var SuperSchemaTests = []SuperSchemaTest{
strCol("", 4, false),
strCol("", 5, false),
}),
tagNames: map[uint64][]string{ 1: {"aaa", "aa", "a"}, 2: {"bbb", "b"}, 3: {"c"}, 4: {"dd"}, 5: {"eee"}},
tagNames: map[uint64][]string{1: {"aaa", "aa", "a"}, 2: {"bbb", "b"}, 3: {"c"}, 4: {"dd"}, 5: {"eee"}},
},
ExpectedGeneratedSchema: mustSchema([]Column{
strCol("aaa", 1, true),
@@ -104,8 +105,8 @@ var SuperSchemaTests = []SuperSchemaTest{
}),
},
{
Name: "SuperSchema respects order of added Schemas",
Schemas: []Schema{ sch3, sch2, sch1 },
Name: "SuperSchema respects order of added Schemas",
Schemas: []Schema{sch3, sch2, sch1},
ExpectedSuperSchema: SuperSchema{
allCols: mustColColl([]Column{
strCol("", 1, true),
@@ -114,7 +115,7 @@ var SuperSchemaTests = []SuperSchemaTest{
strCol("", 4, false),
strCol("", 3, false),
}),
tagNames: map[uint64][]string{ 1: {"a", "aa", "aaa"}, 2: {"b", "bbb"}, 3: {"c"}, 4: {"dd"}, 5: {"eee"}},
tagNames: map[uint64][]string{1: {"a", "aa", "aaa"}, 2: {"b", "bbb"}, 3: {"c"}, 4: {"dd"}, 5: {"eee"}},
},
ExpectedGeneratedSchema: mustSchema([]Column{
strCol("a", 1, true),
@@ -125,8 +126,8 @@ var SuperSchemaTests = []SuperSchemaTest{
}),
},
{
Name: "SuperSchema appends tag to disambiguate name collisions",
Schemas: []Schema{ sch1, nameCollisionWithSch1 },
Name: "SuperSchema appends tag to disambiguate name collisions",
Schemas: []Schema{sch1, nameCollisionWithSch1},
ExpectedSuperSchema: SuperSchema{
allCols: mustColColl([]Column{
strCol("", 1, true),
@@ -134,8 +135,8 @@ var SuperSchemaTests = []SuperSchemaTest{
strCol("", 3, false),
strCol("", 22, false),
}),
tagNames: map[uint64][]string{ 1: {"a"}, 2: {"b"}, 3: {"c"}, 22: {"b"}},
},
tagNames: map[uint64][]string{1: {"a"}, 2: {"b"}, 3: {"c"}, 22: {"b"}},
},
ExpectedGeneratedSchema: mustSchema([]Column{
strCol("a", 1, true),
strCol("b_2", 2, false),
@@ -144,8 +145,8 @@ var SuperSchemaTests = []SuperSchemaTest{
}),
},
{
Name: "SuperSchema errors on tag collision",
Schemas: []Schema{ sch1, tagCollisionWithSch1 },
Name: "SuperSchema errors on tag collision",
Schemas: []Schema{sch1, tagCollisionWithSch1},
ExpectedErrString: "tag collision for columns b and collision, different definitions (tag: 2)",
},
}
@@ -238,4 +239,4 @@ func mustColColl(cols []Column) *ColCollection {
func strCol(name string, tag uint64, isPK bool) Column {
return Column{name, tag, types.StringKind, isPK, typeinfo.StringDefaultType, nil}
}
}
+1 -1
View File
@@ -17,7 +17,6 @@ package sqle
import (
"context"
"fmt"
"github.com/liquidata-inc/dolt/go/libraries/doltcore/schema"
"io"
"strings"
"sync"
@@ -32,6 +31,7 @@ import (
"github.com/liquidata-inc/dolt/go/libraries/doltcore/doltdb"
"github.com/liquidata-inc/dolt/go/libraries/doltcore/env"
"github.com/liquidata-inc/dolt/go/libraries/doltcore/env/actions/commitwalk"
"github.com/liquidata-inc/dolt/go/libraries/doltcore/schema"
"github.com/liquidata-inc/dolt/go/libraries/doltcore/schema/alterschema"
dsql "github.com/liquidata-inc/dolt/go/libraries/doltcore/sql"
"github.com/liquidata-inc/dolt/go/store/hash"
-1
View File
@@ -46,7 +46,6 @@ func (s *StrSet) Add(items ...string) {
}
}
// Remove removes existing items from the set
func (s *StrSet) Remove(items ...string) {
for _, item := range items {
+2 -1
View File
@@ -15,10 +15,11 @@
package set
import (
"github.com/stretchr/testify/assert"
"reflect"
"sort"
"testing"
"github.com/stretchr/testify/assert"
)
func TestStrSet(t *testing.T) {