mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-14 19:20:44 -05:00
go/libraries/doltcore/shema/typeinfo: Fix up tests for ValueStore carrying a *sync.Cond.
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
)
|
||||
|
||||
func TestBlobStringConvertNomsValueToValue(t *testing.T) {
|
||||
vrw := types.NewMemoryValueStore()
|
||||
tests := []struct {
|
||||
typ *blobStringType
|
||||
input types.Blob
|
||||
@@ -37,19 +38,19 @@ func TestBlobStringConvertNomsValueToValue(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
generateBlobStringType(t, 10),
|
||||
mustBlobString(t, "0 "),
|
||||
mustBlobString(t, vrw, "0 "),
|
||||
"0 ",
|
||||
false,
|
||||
},
|
||||
{
|
||||
generateBlobStringType(t, 80),
|
||||
mustBlobString(t, "this is some text that will be returned"),
|
||||
mustBlobString(t, vrw, "this is some text that will be returned"),
|
||||
"this is some text that will be returned",
|
||||
false,
|
||||
},
|
||||
{
|
||||
&blobStringType{gmstypes.CreateLongText(sql.Collation_Default)},
|
||||
mustBlobString(t, " This is a sentence. "),
|
||||
mustBlobString(t, vrw, " This is a sentence. "),
|
||||
" This is a sentence. ",
|
||||
false,
|
||||
},
|
||||
@@ -69,6 +70,7 @@ func TestBlobStringConvertNomsValueToValue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBlobStringConvertValueToNomsValue(t *testing.T) {
|
||||
vrw := types.NewMemoryValueStore()
|
||||
tests := []struct {
|
||||
typ *blobStringType
|
||||
input interface{}
|
||||
@@ -78,32 +80,31 @@ func TestBlobStringConvertValueToNomsValue(t *testing.T) {
|
||||
{
|
||||
generateBlobStringType(t, 10),
|
||||
"0 ",
|
||||
mustBlobString(t, "0 "),
|
||||
mustBlobString(t, vrw, "0 "),
|
||||
false,
|
||||
},
|
||||
{
|
||||
generateBlobStringType(t, 80),
|
||||
int64(28354),
|
||||
mustBlobString(t, "28354"),
|
||||
mustBlobString(t, vrw, "28354"),
|
||||
false,
|
||||
},
|
||||
{
|
||||
&blobStringType{gmstypes.CreateLongText(sql.Collation_Default)},
|
||||
float32(3724.75),
|
||||
mustBlobString(t, "3724.75"),
|
||||
mustBlobString(t, vrw, "3724.75"),
|
||||
false,
|
||||
},
|
||||
{
|
||||
generateBlobStringType(t, 80),
|
||||
time.Date(2030, 1, 2, 4, 6, 3, 472382485, time.UTC),
|
||||
mustBlobString(t, "2030-01-02 04:06:03.472382"),
|
||||
mustBlobString(t, vrw, "2030-01-02 04:06:03.472382"),
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(fmt.Sprintf(`%v %v`, test.typ.String(), test.input), func(t *testing.T) {
|
||||
vrw := types.NewMemoryValueStore()
|
||||
output, err := test.typ.ConvertValueToNomsValue(context.Background(), vrw, test.input)
|
||||
if !test.expectedErr {
|
||||
require.NoError(t, err)
|
||||
@@ -116,6 +117,7 @@ func TestBlobStringConvertValueToNomsValue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBlobStringFormatValue(t *testing.T) {
|
||||
vrw := types.NewMemoryValueStore()
|
||||
tests := []struct {
|
||||
typ *blobStringType
|
||||
input types.Blob
|
||||
@@ -124,19 +126,19 @@ func TestBlobStringFormatValue(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
generateBlobStringType(t, 10),
|
||||
mustBlobString(t, "0 "),
|
||||
mustBlobString(t, vrw, "0 "),
|
||||
"0 ",
|
||||
false,
|
||||
},
|
||||
{
|
||||
generateBlobStringType(t, 80),
|
||||
mustBlobString(t, "this is some text that will be returned"),
|
||||
mustBlobString(t, vrw, "this is some text that will be returned"),
|
||||
"this is some text that will be returned",
|
||||
false,
|
||||
},
|
||||
{
|
||||
&blobStringType{gmstypes.CreateLongText(sql.Collation_Default)},
|
||||
mustBlobString(t, " This is a sentence. "),
|
||||
mustBlobString(t, vrw, " This is a sentence. "),
|
||||
" This is a sentence. ",
|
||||
false,
|
||||
},
|
||||
@@ -156,6 +158,7 @@ func TestBlobStringFormatValue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBlobStringParseValue(t *testing.T) {
|
||||
vrw := types.NewMemoryValueStore()
|
||||
tests := []struct {
|
||||
typ *blobStringType
|
||||
input string
|
||||
@@ -165,26 +168,25 @@ func TestBlobStringParseValue(t *testing.T) {
|
||||
{
|
||||
generateBlobStringType(t, 10),
|
||||
"0 ",
|
||||
mustBlobString(t, "0 "),
|
||||
mustBlobString(t, vrw, "0 "),
|
||||
false,
|
||||
},
|
||||
{
|
||||
generateBlobStringType(t, 80),
|
||||
"this is some text that will be returned",
|
||||
mustBlobString(t, "this is some text that will be returned"),
|
||||
mustBlobString(t, vrw, "this is some text that will be returned"),
|
||||
false,
|
||||
},
|
||||
{
|
||||
&blobStringType{gmstypes.CreateLongText(sql.Collation_Default)},
|
||||
" This is a sentence. ",
|
||||
mustBlobString(t, " This is a sentence. "),
|
||||
mustBlobString(t, vrw, " This is a sentence. "),
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(fmt.Sprintf(`%v %v`, test.typ.String(), test.input), func(t *testing.T) {
|
||||
vrw := types.NewMemoryValueStore()
|
||||
output, err := StringDefaultType.ConvertToType(context.Background(), vrw, test.typ, types.String(test.input))
|
||||
if !test.expectedErr {
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -168,8 +168,7 @@ func generateBlobStringType(t *testing.T, length int64) *blobStringType {
|
||||
return &blobStringType{gmstypes.MustCreateStringWithDefaults(sqltypes.Text, length)}
|
||||
}
|
||||
|
||||
func mustBlobString(t *testing.T, str string) types.Blob {
|
||||
vrw := types.NewMemoryValueStore()
|
||||
func mustBlobString(t *testing.T, vrw types.ValueReadWriter, str string) types.Blob {
|
||||
blob, err := types.NewBlob(context.Background(), vrw, strings.NewReader(str))
|
||||
require.NoError(t, err)
|
||||
return blob
|
||||
|
||||
@@ -32,7 +32,8 @@ import (
|
||||
|
||||
func TestTypeInfoSuite(t *testing.T) {
|
||||
t.Skip()
|
||||
typeInfoArrays, validTypeValues := generateTypeInfoArrays(t)
|
||||
vrw := types.NewMemoryValueStore()
|
||||
typeInfoArrays, validTypeValues := generateTypeInfoArrays(t, vrw)
|
||||
t.Run("VerifyArray", func(t *testing.T) {
|
||||
verifyTypeInfoArrays(t, typeInfoArrays, validTypeValues)
|
||||
})
|
||||
@@ -343,7 +344,7 @@ func testTypeInfoConversionsExist(t *testing.T, tiArrays [][]TypeInfo) {
|
||||
}
|
||||
|
||||
// generate unique TypeInfos for each type, and also values that are valid for at least one of the TypeInfos for the matching row
|
||||
func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) {
|
||||
func generateTypeInfoArrays(t *testing.T, vrw types.ValueReadWriter) ([][]TypeInfo, [][]types.Value) {
|
||||
return [][]TypeInfo{
|
||||
generateBitTypes(t, 16),
|
||||
{&blobStringType{gmstypes.TinyText}, &blobStringType{gmstypes.Text},
|
||||
@@ -377,8 +378,8 @@ func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) {
|
||||
},
|
||||
[][]types.Value{
|
||||
{types.Uint(1), types.Uint(207), types.Uint(79147), types.Uint(34845728), types.Uint(9274618927)}, //Bit
|
||||
{mustBlobString(t, ""), mustBlobString(t, "a"), mustBlobString(t, "abc"), //BlobString
|
||||
mustBlobString(t, "abcdefghijklmnopqrstuvwxyz"), mustBlobString(t, "هذا هو بعض نماذج النص التي أستخدمها لاختبار عناصر")},
|
||||
{mustBlobString(t, vrw, ""), mustBlobString(t, vrw, "a"), mustBlobString(t, vrw, "abc"), //BlobString
|
||||
mustBlobString(t, vrw, "abcdefghijklmnopqrstuvwxyz"), mustBlobString(t, vrw, "هذا هو بعض نماذج النص التي أستخدمها لاختبار عناصر")},
|
||||
{types.Bool(false), types.Bool(true)}, //Bool
|
||||
{types.Timestamp(time.Date(1000, 1, 1, 0, 0, 0, 0, time.UTC)), //Datetime
|
||||
types.Timestamp(time.Date(1970, 1, 1, 0, 0, 1, 0, time.UTC)),
|
||||
|
||||
Reference in New Issue
Block a user