move test fns

This commit is contained in:
Dhruv Sringari
2022-05-03 09:22:52 -07:00
parent a297892f40
commit 47865fe067
2 changed files with 13 additions and 16 deletions

View File

@@ -307,14 +307,14 @@ func TestMergeCommits(t *testing.T) {
mergedRows, err := merged.GetRowData(context.Background())
assert.NoError(t, err)
prolly.MustEqual(t, durable.ProllyMapFromIndex(expectedRows), durable.ProllyMapFromIndex(mergedRows))
MustEqualProlly(t, durable.ProllyMapFromIndex(expectedRows), durable.ProllyMapFromIndex(mergedRows))
for _, index := range sch.Indexes().AllIndexes() {
mergedIndexRows, err := merged.GetIndexRowData(context.Background(), index.Name())
require.NoError(t, err)
expectedIndexRows, err := expected.GetIndexRowData(context.Background(), index.Name())
require.NoError(t, err)
prolly.MustEqual(t, durable.ProllyMapFromIndex(expectedIndexRows), durable.ProllyMapFromIndex(mergedIndexRows))
MustEqualProlly(t, durable.ProllyMapFromIndex(expectedIndexRows), durable.ProllyMapFromIndex(mergedIndexRows))
}
h, err := merged.HashOf()
@@ -752,6 +752,17 @@ func mustString(str string, err error) string {
return str
}
func MustDebugFormatProlly(t *testing.T, m prolly.Map) string {
s, err := prolly.DebugFormat(context.Background(), m)
require.NoError(t, err)
return s
}
func MustEqualProlly(t *testing.T, expected prolly.Map, actual prolly.Map) {
require.Equal(t, expected.HashOf(), actual.HashOf(),
"hashes differed. expected: %s\nactual: %s", MustDebugFormatProlly(t, expected), MustDebugFormatProlly(t, actual))
}
//func diffStr(t tree.Diff, kD val.TupleDesc) string {
// var str string
// switch t.Type {

View File

@@ -19,9 +19,6 @@ import (
"fmt"
"io"
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/dolthub/dolt/go/store/hash"
"github.com/dolthub/dolt/go/store/prolly/tree"
@@ -273,14 +270,3 @@ func DebugFormat(ctx context.Context, m Map) (string, error) {
sb.WriteString("}")
return sb.String(), nil
}
func MustDebugFormat(t *testing.T, m Map) string {
s, err := DebugFormat(context.Background(), m)
require.NoError(t, err)
return s
}
func MustEqual(t *testing.T, expected Map, actual Map) {
require.Equal(t, expected.HashOf(), actual.HashOf(),
"hashes differed. expected: %s\nactual: %s", MustDebugFormat(t, expected), MustDebugFormat(t, actual))
}