mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-21 11:29:51 -05:00
dolt/go: Changes from Equals not taking *Format.
This commit is contained in:
committed by
Brian Hendriks
parent
2a3a0988eb
commit
80c2e40b60
@@ -39,7 +39,7 @@ func (dr *DimRow) StoreValue(me *types.MapEditor) *types.MapEditor {
|
||||
typedSch := dr.toTyped.DestSch
|
||||
key := typed.NomsMapKey(types.Format_7_18, typedSch).Value(context.Background())
|
||||
|
||||
if !dr.key.Equals(types.Format_7_18, key) {
|
||||
if !dr.key.Equals(key) {
|
||||
me = me.Remove(dr.key)
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (dr *DimRow) HasChanged() bool {
|
||||
equal := true
|
||||
dr.currentVals.Iter(func(tag uint64, val types.Value) bool {
|
||||
val2, ok := dr.dbVals.Get(tag)
|
||||
equal = ok && val.Equals(types.Format_7_18, val2)
|
||||
equal = ok && val.Equals(val2)
|
||||
|
||||
return !equal
|
||||
})
|
||||
|
||||
+1
-2
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/env"
|
||||
"github.com/liquidata-inc/ld/dolt/go/libraries/utils/filesys"
|
||||
"github.com/liquidata-inc/ld/dolt/go/libraries/utils/iohelp"
|
||||
"github.com/liquidata-inc/ld/dolt/go/store/types"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
@@ -96,7 +95,7 @@ func main() {
|
||||
dim := New(ctx, sch, data)
|
||||
updatedRows := dim.Run(ctx)
|
||||
|
||||
if !data.Equals(types.Format_7_18, updatedRows) {
|
||||
if !data.Equals(updatedRows) {
|
||||
updatedTbl := tbl.UpdateRows(ctx, updatedRows)
|
||||
updatedRoot := root.PutTable(ctx, dEnv.DoltDB, tableName, updatedTbl)
|
||||
dEnv.UpdateWorkingRoot(ctx, updatedRoot)
|
||||
|
||||
@@ -130,7 +130,7 @@ func TestParseKeyValues(t *testing.T) {
|
||||
currActual = actual[i]
|
||||
}
|
||||
|
||||
if !currActual.Equals(types.Format_7_18, currExpected) {
|
||||
if !currActual.Equals(currExpected) {
|
||||
t.Error("actual:", types.EncodedValue(context.Background(), types.Format_7_18, currActual), "!= expected:", types.EncodedValue(context.Background(), types.Format_7_18, currExpected))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,14 +62,14 @@ func TestPutRow(t *testing.T) {
|
||||
for i, v := range expectedFieldVals {
|
||||
val, fld := row.GetColVal(i)
|
||||
|
||||
if !val.Equals(types.Format_7_18, v) {
|
||||
if !val.Equals(v) {
|
||||
t.Error("Unexpected value for", fld, "expected:", v, "actual:", val)
|
||||
}
|
||||
}
|
||||
|
||||
titleVal, _ := row.GetColVal(dtestutils.TitleTag)
|
||||
|
||||
if !titleVal.Equals(types.Format_7_18, types.String(test.expectedTitle)) {
|
||||
if !titleVal.Equals(types.String(test.expectedTitle)) {
|
||||
t.Error("Value of title was not the expected value. expected", test.expectedTitle, "actual", titleVal)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func parseWhere(sch schema.Schema, whereClause string) (filterFn, error) {
|
||||
return false
|
||||
}
|
||||
|
||||
return val.Equals(types.Format_7_18, rowVal)
|
||||
return val.Equals(rowVal)
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,12 +140,12 @@ func (c *Commit) CanFastForwardTo(ctx context.Context, new *Commit) (bool, error
|
||||
return false, err
|
||||
} else if ancestor == nil {
|
||||
return false, errors.New("cannot perform fast forward merge; commits have no common ancestor")
|
||||
} else if ancestor.commitSt.Equals(c.vrw.Format(), c.commitSt) {
|
||||
if ancestor.commitSt.Equals(c.vrw.Format(), new.commitSt) {
|
||||
} else if ancestor.commitSt.Equals(c.commitSt) {
|
||||
if ancestor.commitSt.Equals(new.commitSt) {
|
||||
return true, ErrUpToDate
|
||||
}
|
||||
return true, nil
|
||||
} else if ancestor.commitSt.Equals(c.vrw.Format(), new.commitSt) {
|
||||
} else if ancestor.commitSt.Equals(new.commitSt) {
|
||||
return false, ErrIsAhead
|
||||
}
|
||||
|
||||
@@ -159,12 +159,12 @@ func (c *Commit) CanFastReverseTo(ctx context.Context, new *Commit) (bool, error
|
||||
return false, err
|
||||
} else if ancestor == nil {
|
||||
return false, errors.New("cannot perform fast forward merge; commits have no common ancestor")
|
||||
} else if ancestor.commitSt.Equals(c.vrw.Format(), new.commitSt) {
|
||||
if ancestor.commitSt.Equals(c.vrw.Format(), c.commitSt) {
|
||||
} else if ancestor.commitSt.Equals(new.commitSt) {
|
||||
if ancestor.commitSt.Equals(c.commitSt) {
|
||||
return true, ErrUpToDate
|
||||
}
|
||||
return true, nil
|
||||
} else if ancestor.commitSt.Equals(c.vrw.Format(), c.commitSt) {
|
||||
} else if ancestor.commitSt.Equals(c.commitSt) {
|
||||
return false, ErrIsBehind
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ func (root *RootValue) TableDiff(ctx context.Context, other *RootValue) (added,
|
||||
pk2, val2 := itr2.Next(ctx)
|
||||
|
||||
for pk1 != nil || pk2 != nil {
|
||||
if pk1 == nil || pk2 == nil || !pk1.Equals(root.vrw.Format(), pk2) {
|
||||
if pk1 == nil || pk2 == nil || !pk1.Equals(pk2) {
|
||||
// TODO(binformat)
|
||||
if pk2 == nil || (pk1 != nil && pk1.Less(root.vrw.Format(), pk2)) {
|
||||
added = append(added, string(pk1.(types.String)))
|
||||
@@ -203,7 +203,7 @@ func (root *RootValue) TableDiff(ctx context.Context, other *RootValue) (added,
|
||||
//tbl1 := Table{root.vrw, tblSt1.(types.Struct)}
|
||||
//tbl2 := Table{root.vrw, tblSt2.(types.Struct)}
|
||||
|
||||
if !val1.Equals(root.vrw.Format(), val2) {
|
||||
if !val1.Equals(val2) {
|
||||
modified = append(modified, string(pk1.(types.String)))
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ func applyChange(me *types.MapEditor, stats *MergeStats, change types.ValueChang
|
||||
func rowMerge(ctx context.Context, format *types.Format, sch schema.Schema, r, mergeRow, baseRow types.Value) (types.Value, bool) {
|
||||
var baseVals row.TaggedValues
|
||||
if baseRow == nil {
|
||||
if r.Equals(format, mergeRow) {
|
||||
if r.Equals(mergeRow) {
|
||||
// same row added to both
|
||||
return r, false
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ func TestMergeCommits(t *testing.T) {
|
||||
|
||||
if merged.HashOf() != expected.HashOf() {
|
||||
mergedRows := merged.GetRowData(context.Background())
|
||||
if !mergedRows.Equals(types.Format_7_18, expectedRows) {
|
||||
if !mergedRows.Equals(expectedRows) {
|
||||
t.Error(types.EncodedValue(context.Background(), types.Format_7_18, mergedRows), "\n!=\n", types.EncodedValue(context.Background(), types.Format_7_18, expectedRows))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func TestGetFieldByName(t *testing.T) {
|
||||
|
||||
if !ok {
|
||||
t.Error("Expected to find value")
|
||||
} else if !val.Equals(types.Format_7_18, lnVal) {
|
||||
} else if !val.Equals(lnVal) {
|
||||
t.Error("Unexpected value")
|
||||
}
|
||||
|
||||
@@ -34,13 +34,13 @@ func TestGetFieldByNameWithDefault(t *testing.T) {
|
||||
|
||||
val := GetFieldByNameWithDefault(lnColName, defVal, r, sch)
|
||||
|
||||
if !val.Equals(types.Format_7_18, lnVal) {
|
||||
if !val.Equals(lnVal) {
|
||||
t.Error("expected:", lnVal, "actual", val)
|
||||
}
|
||||
|
||||
val = GetFieldByNameWithDefault(reservedColName, defVal, r, sch)
|
||||
|
||||
if !val.Equals(types.Format_7_18, defVal) {
|
||||
if !val.Equals(defVal) {
|
||||
t.Error("expected:", defVal, "actual", val)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func (tvs TupleVals) Less(f *types.Format, other types.LesserValuable) bool {
|
||||
|
||||
otherVal := otherTVs.vs[i]
|
||||
|
||||
if !val.Equals(f, otherVal) {
|
||||
if !val.Equals(otherVal) {
|
||||
return val.Less(f, otherVal)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ func TestTaggedTuple_Iter(t *testing.T) {
|
||||
tt.Iter(func(tag uint64, val types.Value) (stop bool) {
|
||||
sum += tag
|
||||
tagStr := strconv.FormatUint(tag, 10)
|
||||
if !types.String(tagStr).Equals(types.Format_7_18, val) {
|
||||
if !types.String(tagStr).Equals(val) {
|
||||
t.Errorf("Unexpected value for tag %d: %s", sum, string(val.(types.String)))
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -194,7 +194,7 @@ func FindRowIndex(find row.Row, rows []row.Row) int {
|
||||
for i, updatedRow := range rows {
|
||||
rowId, _ := find.GetColVal(IdTag)
|
||||
updatedId, _ := updatedRow.GetColVal(IdTag)
|
||||
if rowId.Equals(types.Format_7_18, updatedId) {
|
||||
if rowId.Equals(updatedId) {
|
||||
idx = i
|
||||
break
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ func ExecuteUpdate(ctx context.Context, db *doltdb.DoltDB, root *doltdb.RootValu
|
||||
currVal, _ := r.GetColVal(tag)
|
||||
val := getter.Get(r)
|
||||
|
||||
if (currVal == nil && val != nil) || (currVal != nil && !currVal.Equals(types.Format_7_18, val)) {
|
||||
if (currVal == nil && val != nil) || (currVal != nil && !currVal.Equals(val)) {
|
||||
anyColChanged = true
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ func getterFor(expr sqlparser.Expr, inputSchemas map[string]schema.Schema, alias
|
||||
switch e.Operator {
|
||||
case sqlparser.EqualStr:
|
||||
predicate = func(left, right types.Value) bool {
|
||||
return left.Equals(types.Format_7_18, right)
|
||||
return left.Equals(right)
|
||||
}
|
||||
case sqlparser.LessThanStr:
|
||||
predicate = func(left, right types.Value) bool {
|
||||
@@ -273,16 +273,16 @@ func getterFor(expr sqlparser.Expr, inputSchemas map[string]schema.Schema, alias
|
||||
case sqlparser.LessEqualStr:
|
||||
predicate = func(left, right types.Value) bool {
|
||||
// TODO(binformat)
|
||||
return left.Less(types.Format_7_18, right) || left.Equals(types.Format_7_18, right)
|
||||
return left.Less(types.Format_7_18, right) || left.Equals(right)
|
||||
}
|
||||
case sqlparser.GreaterEqualStr:
|
||||
predicate = func(left, right types.Value) bool {
|
||||
// TODO(binformat)
|
||||
return right.Less(types.Format_7_18, left) || right.Equals(types.Format_7_18, left)
|
||||
return right.Less(types.Format_7_18, left) || right.Equals(left)
|
||||
}
|
||||
case sqlparser.NotEqualStr:
|
||||
predicate = func(left, right types.Value) bool {
|
||||
return !left.Equals(types.Format_7_18, right)
|
||||
return !left.Equals(right)
|
||||
}
|
||||
case sqlparser.InStr:
|
||||
predicate = func(left, right types.Value) bool {
|
||||
@@ -379,7 +379,7 @@ func getterFor(expr sqlparser.Expr, inputSchemas map[string]schema.Schema, alias
|
||||
return types.Bool(false)
|
||||
}
|
||||
// TODO: this may not be the correct nullness semantics for "is not" comparisons
|
||||
if val.Equals(types.Format_7_18, types.Bool(true)) {
|
||||
if val.Equals(types.Bool(true)) {
|
||||
return types.Bool(op == sqlparser.IsTrueStr || op == sqlparser.IsNotFalseStr)
|
||||
} else {
|
||||
return types.Bool(op == sqlparser.IsFalseStr || op == sqlparser.IsNotTrueStr)
|
||||
|
||||
@@ -80,7 +80,7 @@ func TestConv(t *testing.T) {
|
||||
t.Error("input:", test.input, "expected err:", test.expectErr, "actual err:", err != nil)
|
||||
}
|
||||
|
||||
if !test.expectedOut.Equals(types.Format_7_18, result) {
|
||||
if !test.expectedOut.Equals(result) {
|
||||
t.Error("input:", test.input, "expected result:", test.expectedOut, "actual result:", result)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@ func NilSafeEqCheck(f *types.Format, v1, v2 types.Value) bool {
|
||||
if types.IsNull(v1) {
|
||||
return types.IsNull(v2)
|
||||
} else {
|
||||
return v1.Equals(f, v2)
|
||||
return v1.Equals(v2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func (bl branchList) HighestBranchIndexes() []int {
|
||||
maxHeight = b.cr.Height()
|
||||
cr = b.cr
|
||||
cols = []int{i}
|
||||
} else if b.cr.Height() == maxHeight && b.cr.Equals(b.cr.Format(), cr) {
|
||||
} else if b.cr.Height() == maxHeight && b.cr.Equals(cr) {
|
||||
cols = append(cols, i)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ func (s *nomsCommitTestSuite) TestNomsCommitToDatasetWithoutHead() {
|
||||
func structFieldEqual(old, now types.Struct, field string) bool {
|
||||
oldValue, oldOk := old.MaybeGet(field)
|
||||
nowValue, nowOk := now.MaybeGet(field)
|
||||
return oldOk && nowOk && nowValue.Equals(types.Format_7_18, oldValue)
|
||||
return oldOk && nowOk && nowValue.Equals(oldValue)
|
||||
}
|
||||
|
||||
func (s *nomsCommitTestSuite) runDuplicateTest(allowDuplicate bool) {
|
||||
@@ -161,10 +161,10 @@ func (s *nomsCommitTestSuite) TestNomsCommitMetadata() {
|
||||
|
||||
metaNew := sp.GetDataset(context.Background()).Head().Get(datas.MetaField).(types.Struct)
|
||||
|
||||
s.False(metaOld.Equals(types.Format_7_18, metaNew), "meta didn't change")
|
||||
s.False(metaOld.Equals(metaNew), "meta didn't change")
|
||||
s.False(structFieldEqual(metaOld, metaNew, "date"), "date didn't change")
|
||||
s.False(structFieldEqual(metaOld, metaNew, "message"), "message didn't change")
|
||||
s.True(metaNew.Get("message").Equals(types.Format_7_18, types.String("foo")), "message wasn't set")
|
||||
s.True(metaNew.Get("message").Equals(types.String("foo")), "message wasn't set")
|
||||
|
||||
metaOld = metaNew
|
||||
|
||||
@@ -177,10 +177,10 @@ func (s *nomsCommitTestSuite) TestNomsCommitMetadata() {
|
||||
|
||||
metaNew = sp.GetDataset(context.Background()).Head().Get(datas.MetaField).(types.Struct)
|
||||
|
||||
s.False(metaOld.Equals(types.Format_7_18, metaNew), "meta didn't change")
|
||||
s.False(metaOld.Equals(metaNew), "meta didn't change")
|
||||
s.False(structFieldEqual(metaOld, metaNew, "date"), "date didn't change")
|
||||
s.False(structFieldEqual(metaOld, metaNew, "message"), "message didn't change")
|
||||
s.True(metaNew.Get("message").Equals(types.Format_7_18, types.String("bar")), "message wasn't set")
|
||||
s.True(metaNew.Get("message").Equals(types.String("bar")), "message wasn't set")
|
||||
}
|
||||
|
||||
func (s *nomsCommitTestSuite) TestNomsCommitHashNotFound() {
|
||||
|
||||
@@ -275,7 +275,7 @@ func writeMetaLines(ctx context.Context, f *types.Format, node LogNode, maxLines
|
||||
fmt.Fprintf(pw, "%-*s", maxLabelLen+2, strings.Title(fieldName)+":")
|
||||
// Encode dates as formatted string if this is a top-level meta
|
||||
// field of type datetime.DateTimeType
|
||||
if types.TypeOf(v).Equals(f, datetime.DateTimeType) {
|
||||
if types.TypeOf(v).Equals(datetime.DateTimeType) {
|
||||
var dt datetime.DateTime
|
||||
err = dt.UnmarshalNoms(ctx, f, v)
|
||||
|
||||
|
||||
@@ -114,9 +114,9 @@ func (s *nomsMergeTestSuite) validateDataset(name string, expected types.Struct,
|
||||
if s.NoError(err) {
|
||||
defer sp.Close()
|
||||
commit := sp.GetDataset(context.Background()).Head()
|
||||
s.True(commit.Get(datas.ParentsField).Equals(types.Format_7_18, types.NewSet(context.Background(), db, parents...)))
|
||||
s.True(commit.Get(datas.ParentsField).Equals(types.NewSet(context.Background(), db, parents...)))
|
||||
merged := sp.GetDataset(context.Background()).HeadValue()
|
||||
s.True(expected.Equals(types.Format_7_18, merged), "%s != %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, merged))
|
||||
s.True(expected.Equals(merged), "%s != %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, merged))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ func TestNomsMergeCliResolve(t *testing.T) {
|
||||
assert.False(t, ok)
|
||||
} else if assert.True(t, ok) {
|
||||
assert.Equal(t, c.expectedChange, changeType)
|
||||
assert.True(t, c.expected.Equals(types.Format_7_18, newVal))
|
||||
assert.True(t, c.expected.Equals(newVal))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func (s *nomsShowTestSuite) TestNomsShowRaw() {
|
||||
spec.CreateValueSpecString(db.Format(), "nbs", s.DBDir, "#"+r1.TargetHash().String())})
|
||||
ch := chunks.NewChunk([]byte(res))
|
||||
out := types.DecodeValue(ch, db)
|
||||
s.True(out.Equals(db.Format(), in))
|
||||
s.True(out.Equals(in))
|
||||
}
|
||||
|
||||
// Primitive value with no child chunks
|
||||
|
||||
@@ -108,7 +108,7 @@ func runSync(ctx context.Context, args []string) int {
|
||||
status.Done()
|
||||
} else if !sinkExists {
|
||||
fmt.Printf("All chunks already exist at destination! Created new dataset %s.\n", args[1])
|
||||
} else if nonFF && !sourceRef.Equals(sourceStore.Format(), sinkRef) {
|
||||
} else if nonFF && !sourceRef.Equals(sinkRef) {
|
||||
fmt.Printf("Abandoning %s; new head is %s\n", sinkRef.TargetHash(), sourceRef.TargetHash())
|
||||
} else {
|
||||
fmt.Printf("Dataset %s is already up to date.\n", args[1])
|
||||
|
||||
@@ -72,7 +72,7 @@ func (s *nomsSyncTestSuite) TestSync() {
|
||||
s.NoError(err)
|
||||
db := datas.NewDatabase(cs)
|
||||
dest := db.GetDataset(context.Background(), "dest")
|
||||
s.True(types.Float(42).Equals(types.Format_7_18, dest.HeadValue()))
|
||||
s.True(types.Float(42).Equals(dest.HeadValue()))
|
||||
db.Close()
|
||||
|
||||
// Pull from a dataset in one DB to an existing dataset in another
|
||||
@@ -84,7 +84,7 @@ func (s *nomsSyncTestSuite) TestSync() {
|
||||
s.NoError(err)
|
||||
db = datas.NewDatabase(cs)
|
||||
dest = db.GetDataset(context.Background(), "dest")
|
||||
s.True(types.Float(43).Equals(types.Format_7_18, dest.HeadValue()))
|
||||
s.True(types.Float(43).Equals(dest.HeadValue()))
|
||||
db.Close()
|
||||
|
||||
// Pull when sink dataset is already up to date
|
||||
@@ -100,7 +100,7 @@ func (s *nomsSyncTestSuite) TestSync() {
|
||||
s.NoError(err)
|
||||
db = datas.NewDatabase(cs)
|
||||
dest = db.GetDataset(context.Background(), "dest2")
|
||||
s.True(types.Float(43).Equals(types.Format_7_18, dest.HeadValue()))
|
||||
s.True(types.Float(43).Equals(dest.HeadValue()))
|
||||
db.Close()
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ func (s *nomsSyncTestSuite) TestSync_Issue2598() {
|
||||
cs, err = nbs.NewLocalStore(context.Background(), s.DBDir2, clienttest.DefaultMemTableSize)
|
||||
db := datas.NewDatabase(cs)
|
||||
dest := db.GetDataset(context.Background(), "dest")
|
||||
s.True(types.Float(43).Equals(types.Format_7_18, dest.HeadValue()))
|
||||
s.True(types.Float(43).Equals(dest.HeadValue()))
|
||||
db.Close()
|
||||
|
||||
// Now, try syncing a second dataset. This crashed in issue #2598
|
||||
@@ -142,7 +142,7 @@ func (s *nomsSyncTestSuite) TestSync_Issue2598() {
|
||||
s.NoError(err)
|
||||
db = datas.NewDatabase(cs)
|
||||
dest = db.GetDataset(context.Background(), "dest2")
|
||||
s.True(types.Float(1).Equals(types.Format_7_18, dest.HeadValue()))
|
||||
s.True(types.Float(1).Equals(dest.HeadValue()))
|
||||
db.Close()
|
||||
|
||||
sout, _ = s.MustRun(main, []string{"sync", sourceDataset, sinkDatasetSpec})
|
||||
@@ -170,6 +170,6 @@ func (s *nomsSyncTestSuite) TestRewind() {
|
||||
s.NoError(err)
|
||||
db := datas.NewDatabase(cs)
|
||||
dest := db.GetDataset(context.Background(), "foo")
|
||||
s.True(types.Float(42).Equals(types.Format_7_18, dest.HeadValue()))
|
||||
s.True(types.Float(42).Equals(dest.HeadValue()))
|
||||
db.Close()
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ func TestNewCommit(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
assertTypeEquals := func(e, a *types.Type) {
|
||||
assert.True(a.Equals(types.Format_7_18, e), "Actual: %s\nExpected %s", a.Describe(context.Background(), types.Format_7_18), e.Describe(context.Background(), types.Format_7_18))
|
||||
assert.True(a.Equals(e), "Actual: %s\nExpected %s", a.Describe(context.Background(), types.Format_7_18), e.Describe(context.Background(), types.Format_7_18))
|
||||
}
|
||||
|
||||
storage := &chunks.TestStorage{}
|
||||
@@ -142,7 +142,7 @@ func TestFindCommonAncestor(t *testing.T) {
|
||||
if found, ok := FindCommonAncestor(context.Background(), types.Format_7_18, types.NewRef(a, types.Format_7_18), types.NewRef(b, types.Format_7_18), db); assert.True(ok) {
|
||||
ancestor := found.TargetValue(context.Background(), db).(types.Struct)
|
||||
assert.True(
|
||||
expected.Equals(types.Format_7_18, ancestor),
|
||||
expected.Equals(ancestor),
|
||||
"%s should be common ancestor of %s, %s. Got %s",
|
||||
expected.Get(ValueField),
|
||||
a.Get(ValueField),
|
||||
|
||||
@@ -101,7 +101,7 @@ func (db *database) SetHead(ctx context.Context, ds Dataset, newHeadRef types.Re
|
||||
}
|
||||
|
||||
func (db *database) doSetHead(ctx context.Context, ds Dataset, newHeadRef types.Ref) error {
|
||||
if currentHeadRef, ok := ds.MaybeHeadRef(); ok && newHeadRef.Equals(db.Format(), currentHeadRef) {
|
||||
if currentHeadRef, ok := ds.MaybeHeadRef(); ok && newHeadRef.Equals(currentHeadRef) {
|
||||
return nil
|
||||
}
|
||||
commit := db.validateRefAsCommit(ctx, newHeadRef)
|
||||
@@ -119,7 +119,7 @@ func (db *database) FastForward(ctx context.Context, ds Dataset, newHeadRef type
|
||||
|
||||
func (db *database) doFastForward(ctx context.Context, ds Dataset, newHeadRef types.Ref) error {
|
||||
currentHeadRef, ok := ds.MaybeHeadRef()
|
||||
if ok && newHeadRef.Equals(db.Format(), currentHeadRef) {
|
||||
if ok && newHeadRef.Equals(currentHeadRef) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ func (db *database) doDelete(ctx context.Context, datasetIDstr string) error {
|
||||
}
|
||||
// If the optimistic lock failed because someone changed the Head of datasetID, then return ErrMergeNeeded. If it failed because someone changed a different Dataset, we should try again.
|
||||
currentRootHash, currentDatasets = db.rt.Root(ctx), db.Datasets(ctx)
|
||||
if r, hasHead := currentDatasets.MaybeGet(ctx, datasetID); !hasHead || (hasHead && !initialHead.Equals(db.Format(), r)) {
|
||||
if r, hasHead := currentDatasets.MaybeGet(ctx, datasetID); !hasHead || (hasHead && !initialHead.Equals(r)) {
|
||||
err = ErrMergeNeeded
|
||||
break
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func (suite *DatabaseSuite) TestRebase() {
|
||||
b := types.String("b")
|
||||
ds1, err = suite.db.CommitValue(context.Background(), ds1, b)
|
||||
suite.NoError(err)
|
||||
suite.True(ds1.HeadValue().Equals(types.Format_7_18, b))
|
||||
suite.True(ds1.HeadValue().Equals(b))
|
||||
|
||||
interloper := suite.makeDb(suite.storage.NewView())
|
||||
defer interloper.Close()
|
||||
@@ -120,13 +120,13 @@ func (suite *DatabaseSuite) TestRebase() {
|
||||
e := types.String("e")
|
||||
iDS, concErr := interloper.CommitValue(context.Background(), interloper.GetDataset(context.Background(), datasetID), e)
|
||||
suite.NoError(concErr)
|
||||
suite.True(iDS.HeadValue().Equals(types.Format_7_18, e))
|
||||
suite.True(iDS.HeadValue().Equals(e))
|
||||
|
||||
// suite.ds shouldn't see the above change yet
|
||||
suite.True(suite.db.GetDataset(context.Background(), datasetID).HeadValue().Equals(types.Format_7_18, b))
|
||||
suite.True(suite.db.GetDataset(context.Background(), datasetID).HeadValue().Equals(b))
|
||||
|
||||
suite.db.Rebase(context.Background())
|
||||
suite.True(suite.db.GetDataset(context.Background(), datasetID).HeadValue().Equals(types.Format_7_18, e))
|
||||
suite.True(suite.db.GetDataset(context.Background(), datasetID).HeadValue().Equals(e))
|
||||
|
||||
cs := suite.storage.NewView()
|
||||
noChangeDB := suite.makeDb(cs)
|
||||
@@ -156,8 +156,8 @@ func (suite *DatabaseSuite) TestCommitProperlyTracksRoot() {
|
||||
|
||||
suite.EqualValues(ds1HeadVal, ds1.HeadValue())
|
||||
suite.EqualValues(ds2HeadVal, ds2.HeadValue())
|
||||
suite.False(ds2.HeadValue().Equals(types.Format_7_18, ds1HeadVal))
|
||||
suite.False(ds1.HeadValue().Equals(types.Format_7_18, ds2HeadVal))
|
||||
suite.False(ds2.HeadValue().Equals(ds1HeadVal))
|
||||
suite.False(ds1.HeadValue().Equals(ds2HeadVal))
|
||||
}
|
||||
|
||||
func (suite *DatabaseSuite) TestDatabaseCommit() {
|
||||
@@ -172,12 +172,12 @@ func (suite *DatabaseSuite) TestDatabaseCommit() {
|
||||
suite.NoError(err)
|
||||
|
||||
// ds2 matches the Datasets Map in suite.db
|
||||
suite.True(ds2.HeadRef().Equals(types.Format_7_18, suite.db.GetDataset(context.Background(), datasetID).HeadRef()))
|
||||
suite.True(ds2.HeadRef().Equals(suite.db.GetDataset(context.Background(), datasetID).HeadRef()))
|
||||
|
||||
// ds2 has |a| at its head
|
||||
h, ok := ds2.MaybeHeadValue()
|
||||
suite.True(ok)
|
||||
suite.True(h.Equals(types.Format_7_18, a))
|
||||
suite.True(h.Equals(a))
|
||||
suite.Equal(uint64(1), ds2.HeadRef().Height())
|
||||
|
||||
ds = ds2
|
||||
@@ -187,7 +187,7 @@ func (suite *DatabaseSuite) TestDatabaseCommit() {
|
||||
b := types.String("b")
|
||||
ds, err = suite.db.CommitValue(context.Background(), ds, b)
|
||||
suite.NoError(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, b))
|
||||
suite.True(ds.HeadValue().Equals(b))
|
||||
suite.Equal(uint64(2), ds.HeadRef().Height())
|
||||
|
||||
// |a| <- |b|
|
||||
@@ -196,20 +196,20 @@ func (suite *DatabaseSuite) TestDatabaseCommit() {
|
||||
c := types.String("c")
|
||||
ds, err = suite.db.Commit(context.Background(), ds, c, newOpts(suite.db, aCommitRef))
|
||||
suite.Error(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, b))
|
||||
suite.True(ds.HeadValue().Equals(b))
|
||||
|
||||
// |a| <- |b| <- |d|
|
||||
d := types.String("d")
|
||||
ds, err = suite.db.CommitValue(context.Background(), ds, d)
|
||||
suite.NoError(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, d))
|
||||
suite.True(ds.HeadValue().Equals(d))
|
||||
suite.Equal(uint64(3), ds.HeadRef().Height())
|
||||
|
||||
// Attempt to recommit |b| with |a| as parent.
|
||||
// Should be disallowed.
|
||||
ds, err = suite.db.Commit(context.Background(), ds, b, newOpts(suite.db, aCommitRef))
|
||||
suite.Error(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, d))
|
||||
suite.True(ds.HeadValue().Equals(d))
|
||||
|
||||
// Add a commit to a different datasetId
|
||||
_, err = suite.db.CommitValue(context.Background(), suite.db.GetDataset(context.Background(), "otherDS"), a)
|
||||
@@ -320,12 +320,12 @@ func (suite *DatabaseSuite) TestDatabaseCommitMerge() {
|
||||
|
||||
theirs, err := suite.db.Commit(context.Background(), ds1, newV, newOptsWithMerge(suite.db, merge.Theirs, ds1First.HeadRef()))
|
||||
suite.NoError(err)
|
||||
suite.True(types.Bool(true).Equals(types.Format_7_18, theirs.HeadValue().(types.Map).Get(context.Background(), types.String("Friends"))))
|
||||
suite.True(types.Bool(true).Equals(theirs.HeadValue().(types.Map).Get(context.Background(), types.String("Friends"))))
|
||||
|
||||
newV = v.Edit().Set(types.String("Friends"), types.Float(47)).Map(context.Background())
|
||||
ours, err := suite.db.Commit(context.Background(), ds1First, newV, newOptsWithMerge(suite.db, merge.Ours, ds1First.HeadRef()))
|
||||
suite.NoError(err)
|
||||
suite.True(types.Float(47).Equals(types.Format_7_18, ours.HeadValue().(types.Map).Get(context.Background(), types.String("Friends"))))
|
||||
suite.True(types.Float(47).Equals(ours.HeadValue().(types.Map).Get(context.Background(), types.String("Friends"))))
|
||||
}
|
||||
|
||||
func newOptsWithMerge(vrw types.ValueReadWriter, policy merge.ResolveFunc, parents ...types.Value) CommitOptions {
|
||||
@@ -343,17 +343,17 @@ func (suite *DatabaseSuite) TestDatabaseDelete() {
|
||||
a := types.String("a")
|
||||
ds1, err = suite.db.CommitValue(context.Background(), ds1, a)
|
||||
suite.NoError(err)
|
||||
suite.True(ds1.HeadValue().Equals(types.Format_7_18, a))
|
||||
suite.True(ds1.HeadValue().Equals(a))
|
||||
|
||||
// ds1: |a|, ds2: |b|
|
||||
b := types.String("b")
|
||||
ds2, err = suite.db.CommitValue(context.Background(), ds2, b)
|
||||
suite.NoError(err)
|
||||
suite.True(ds2.HeadValue().Equals(types.Format_7_18, b))
|
||||
suite.True(ds2.HeadValue().Equals(b))
|
||||
|
||||
ds1, err = suite.db.Delete(context.Background(), ds1)
|
||||
suite.NoError(err)
|
||||
suite.True(suite.db.GetDataset(context.Background(), datasetID2).HeadValue().Equals(types.Format_7_18, b))
|
||||
suite.True(suite.db.GetDataset(context.Background(), datasetID2).HeadValue().Equals(b))
|
||||
_, present := suite.db.GetDataset(context.Background(), datasetID1).MaybeHead()
|
||||
suite.False(present, "Dataset %s should not be present", datasetID1)
|
||||
|
||||
@@ -377,7 +377,7 @@ func (suite *DatabaseSuite) TestCommitWithConcurrentChunkStoreUse() {
|
||||
b := types.String("b")
|
||||
ds1, err = suite.db.CommitValue(context.Background(), ds1, b)
|
||||
suite.NoError(err)
|
||||
suite.True(ds1.HeadValue().Equals(types.Format_7_18, b))
|
||||
suite.True(ds1.HeadValue().Equals(b))
|
||||
|
||||
// Craft DB that will allow me to move the backing ChunkStore while suite.db isn't looking
|
||||
interloper := suite.makeDb(suite.storage.NewView())
|
||||
@@ -389,13 +389,13 @@ func (suite *DatabaseSuite) TestCommitWithConcurrentChunkStoreUse() {
|
||||
stf := types.String("stuff")
|
||||
ds2, concErr := interloper.CommitValue(context.Background(), interloper.GetDataset(context.Background(), "ds2"), stf)
|
||||
suite.NoError(concErr)
|
||||
suite.True(ds2.HeadValue().Equals(types.Format_7_18, stf))
|
||||
suite.True(ds2.HeadValue().Equals(stf))
|
||||
|
||||
// Change ds1 via suite.db, which should proceed without a problem
|
||||
c := types.String("c")
|
||||
ds1, err = suite.db.CommitValue(context.Background(), ds1, c)
|
||||
suite.NoError(err)
|
||||
suite.True(ds1.HeadValue().Equals(types.Format_7_18, c))
|
||||
suite.True(ds1.HeadValue().Equals(c))
|
||||
|
||||
// Change ds1 behind suite.db's back. Will block changes to ds1 below.
|
||||
// ds1: |a| <- |b| <- |c| <- |e|
|
||||
@@ -403,14 +403,14 @@ func (suite *DatabaseSuite) TestCommitWithConcurrentChunkStoreUse() {
|
||||
interloper.Rebase(context.Background())
|
||||
iDS, concErr := interloper.CommitValue(context.Background(), interloper.GetDataset(context.Background(), "ds1"), e)
|
||||
suite.NoError(concErr)
|
||||
suite.True(iDS.HeadValue().Equals(types.Format_7_18, e))
|
||||
suite.True(iDS.HeadValue().Equals(e))
|
||||
|
||||
// Attempted Concurrent change, which should fail due to the above
|
||||
nope := types.String("nope")
|
||||
ds1, err = suite.db.CommitValue(context.Background(), ds1, nope)
|
||||
suite.Error(err)
|
||||
v := ds1.HeadValue()
|
||||
suite.True(v.Equals(types.Format_7_18, e), "%s", v.(types.String))
|
||||
suite.True(v.Equals(e), "%s", v.(types.String))
|
||||
}
|
||||
|
||||
func (suite *DatabaseSuite) TestDeleteWithConcurrentChunkStoreUse() {
|
||||
@@ -424,7 +424,7 @@ func (suite *DatabaseSuite) TestDeleteWithConcurrentChunkStoreUse() {
|
||||
b := types.String("b")
|
||||
ds1, err = suite.db.CommitValue(context.Background(), ds1, b)
|
||||
suite.NoError(err)
|
||||
suite.True(ds1.HeadValue().Equals(types.Format_7_18, b))
|
||||
suite.True(ds1.HeadValue().Equals(b))
|
||||
|
||||
// Craft DB that will allow me to move the backing ChunkStore while suite.db isn't looking
|
||||
interloper := suite.makeDb(suite.storage.NewView())
|
||||
@@ -435,12 +435,12 @@ func (suite *DatabaseSuite) TestDeleteWithConcurrentChunkStoreUse() {
|
||||
e := types.String("e")
|
||||
iDS, concErr := interloper.CommitValue(context.Background(), interloper.GetDataset(context.Background(), datasetID), e)
|
||||
suite.NoError(concErr)
|
||||
suite.True(iDS.HeadValue().Equals(types.Format_7_18, e))
|
||||
suite.True(iDS.HeadValue().Equals(e))
|
||||
|
||||
// Attempt to delete ds1 via suite.db, which should fail due to the above
|
||||
ds1, err = suite.db.Delete(context.Background(), ds1)
|
||||
suite.Error(err)
|
||||
suite.True(ds1.HeadValue().Equals(types.Format_7_18, e))
|
||||
suite.True(ds1.HeadValue().Equals(e))
|
||||
|
||||
// Concurrent change, but to some other dataset. This shouldn't stop changes to ds1.
|
||||
// ds1: |a| <- |b| <- |e|
|
||||
@@ -448,7 +448,7 @@ func (suite *DatabaseSuite) TestDeleteWithConcurrentChunkStoreUse() {
|
||||
stf := types.String("stuff")
|
||||
iDS, concErr = interloper.CommitValue(context.Background(), suite.db.GetDataset(context.Background(), "other"), stf)
|
||||
suite.NoError(concErr)
|
||||
suite.True(iDS.HeadValue().Equals(types.Format_7_18, stf))
|
||||
suite.True(iDS.HeadValue().Equals(stf))
|
||||
|
||||
// Attempted concurrent delete, which should proceed without a problem
|
||||
ds1, err = suite.db.Delete(context.Background(), ds1)
|
||||
@@ -471,16 +471,16 @@ func (suite *DatabaseSuite) TestSetHead() {
|
||||
b := types.String("b")
|
||||
ds, err = suite.db.CommitValue(context.Background(), ds, b)
|
||||
suite.NoError(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, b))
|
||||
suite.True(ds.HeadValue().Equals(b))
|
||||
bCommitRef := ds.HeadRef() // To use in FF SetHead() below.
|
||||
|
||||
ds, err = suite.db.SetHead(context.Background(), ds, aCommitRef)
|
||||
suite.NoError(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, a))
|
||||
suite.True(ds.HeadValue().Equals(a))
|
||||
|
||||
ds, err = suite.db.SetHead(context.Background(), ds, bCommitRef)
|
||||
suite.NoError(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, b))
|
||||
suite.True(ds.HeadValue().Equals(b))
|
||||
}
|
||||
|
||||
func (suite *DatabaseSuite) TestFastForward() {
|
||||
@@ -497,28 +497,28 @@ func (suite *DatabaseSuite) TestFastForward() {
|
||||
b := types.String("b")
|
||||
ds, err = suite.db.CommitValue(context.Background(), ds, b)
|
||||
suite.NoError(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, b))
|
||||
suite.True(ds.HeadValue().Equals(b))
|
||||
|
||||
c := types.String("c")
|
||||
ds, err = suite.db.CommitValue(context.Background(), ds, c)
|
||||
suite.NoError(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, c))
|
||||
suite.True(ds.HeadValue().Equals(c))
|
||||
cCommitRef := ds.HeadRef() // To use in FastForward() below.
|
||||
|
||||
// FastForward should disallow this, as |a| is not a descendant of |c|
|
||||
ds, err = suite.db.FastForward(context.Background(), ds, aCommitRef)
|
||||
suite.Error(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, c))
|
||||
suite.True(ds.HeadValue().Equals(c))
|
||||
|
||||
// Move Head back to something earlier in the lineage, so we can test FastForward
|
||||
ds, err = suite.db.SetHead(context.Background(), ds, aCommitRef)
|
||||
suite.NoError(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, a))
|
||||
suite.True(ds.HeadValue().Equals(a))
|
||||
|
||||
// This should succeed, because while |a| is not a direct parent of |c|, it is an ancestor.
|
||||
ds, err = suite.db.FastForward(context.Background(), ds, cCommitRef)
|
||||
suite.NoError(err)
|
||||
suite.True(ds.HeadValue().Equals(types.Format_7_18, c))
|
||||
suite.True(ds.HeadValue().Equals(c))
|
||||
}
|
||||
|
||||
func (suite *DatabaseSuite) TestDatabaseHeightOfRefs() {
|
||||
|
||||
@@ -27,27 +27,27 @@ func TestExplicitBranchUsingDatasets(t *testing.T) {
|
||||
a := types.String("a")
|
||||
ds1, err := store.CommitValue(context.Background(), ds1, a)
|
||||
assert.NoError(err)
|
||||
assert.True(ds1.Head().Get(ValueField).Equals(types.Format_7_18, a))
|
||||
assert.True(ds1.Head().Get(ValueField).Equals(a))
|
||||
|
||||
// ds1: |a|
|
||||
// \ds2
|
||||
ds2 := store.GetDataset(context.Background(), id2)
|
||||
ds2, err = store.Commit(context.Background(), ds2, ds1.HeadValue(), CommitOptions{Parents: types.NewSet(context.Background(), store, ds1.HeadRef())})
|
||||
assert.NoError(err)
|
||||
assert.True(ds2.Head().Get(ValueField).Equals(types.Format_7_18, a))
|
||||
assert.True(ds2.Head().Get(ValueField).Equals(a))
|
||||
|
||||
// ds1: |a| <- |b|
|
||||
b := types.String("b")
|
||||
ds1, err = store.CommitValue(context.Background(), ds1, b)
|
||||
assert.NoError(err)
|
||||
assert.True(ds1.Head().Get(ValueField).Equals(types.Format_7_18, b))
|
||||
assert.True(ds1.Head().Get(ValueField).Equals(b))
|
||||
|
||||
// ds1: |a| <- |b|
|
||||
// \ds2 <- |c|
|
||||
c := types.String("c")
|
||||
ds2, err = store.CommitValue(context.Background(), ds2, c)
|
||||
assert.NoError(err)
|
||||
assert.True(ds2.Head().Get(ValueField).Equals(types.Format_7_18, c))
|
||||
assert.True(ds2.Head().Get(ValueField).Equals(c))
|
||||
|
||||
// ds1: |a| <- |b| <--|d|
|
||||
// \ds2 <- |c| <--/
|
||||
@@ -55,11 +55,11 @@ func TestExplicitBranchUsingDatasets(t *testing.T) {
|
||||
d := types.String("d")
|
||||
ds2, err = store.Commit(context.Background(), ds2, d, CommitOptions{Parents: mergeParents})
|
||||
assert.NoError(err)
|
||||
assert.True(ds2.Head().Get(ValueField).Equals(types.Format_7_18, d))
|
||||
assert.True(ds2.Head().Get(ValueField).Equals(d))
|
||||
|
||||
ds1, err = store.Commit(context.Background(), ds1, d, CommitOptions{Parents: mergeParents})
|
||||
assert.NoError(err)
|
||||
assert.True(ds1.Head().Get(ValueField).Equals(types.Format_7_18, d))
|
||||
assert.True(ds1.Head().Get(ValueField).Equals(d))
|
||||
}
|
||||
|
||||
func TestTwoClientsWithEmptyDataset(t *testing.T) {
|
||||
@@ -76,7 +76,7 @@ func TestTwoClientsWithEmptyDataset(t *testing.T) {
|
||||
a := types.String("a")
|
||||
dsx, err := store.CommitValue(context.Background(), dsx, a)
|
||||
assert.NoError(err)
|
||||
assert.True(dsx.Head().Get(ValueField).Equals(types.Format_7_18, a))
|
||||
assert.True(dsx.Head().Get(ValueField).Equals(a))
|
||||
|
||||
// dsy: || -> |b|
|
||||
_, ok := dsy.MaybeHead()
|
||||
@@ -88,7 +88,7 @@ func TestTwoClientsWithEmptyDataset(t *testing.T) {
|
||||
// dsy: |a| -> |b|
|
||||
dsy, err = store.CommitValue(context.Background(), dsy, b)
|
||||
assert.NoError(err)
|
||||
assert.True(dsy.Head().Get(ValueField).Equals(types.Format_7_18, b))
|
||||
assert.True(dsy.Head().Get(ValueField).Equals(b))
|
||||
}
|
||||
|
||||
func TestTwoClientsWithNonEmptyDataset(t *testing.T) {
|
||||
@@ -104,30 +104,30 @@ func TestTwoClientsWithNonEmptyDataset(t *testing.T) {
|
||||
ds1 := store.GetDataset(context.Background(), id1)
|
||||
ds1, err := store.CommitValue(context.Background(), ds1, a)
|
||||
assert.NoError(err)
|
||||
assert.True(ds1.Head().Get(ValueField).Equals(types.Format_7_18, a))
|
||||
assert.True(ds1.Head().Get(ValueField).Equals(a))
|
||||
}
|
||||
|
||||
dsx := store.GetDataset(context.Background(), id1)
|
||||
dsy := store.GetDataset(context.Background(), id1)
|
||||
|
||||
// dsx: |a| -> |b|
|
||||
assert.True(dsx.Head().Get(ValueField).Equals(types.Format_7_18, a))
|
||||
assert.True(dsx.Head().Get(ValueField).Equals(a))
|
||||
b := types.String("b")
|
||||
dsx, err := store.CommitValue(context.Background(), dsx, b)
|
||||
assert.NoError(err)
|
||||
assert.True(dsx.Head().Get(ValueField).Equals(types.Format_7_18, b))
|
||||
assert.True(dsx.Head().Get(ValueField).Equals(b))
|
||||
|
||||
// dsy: |a| -> |c|
|
||||
assert.True(dsy.Head().Get(ValueField).Equals(types.Format_7_18, a))
|
||||
assert.True(dsy.Head().Get(ValueField).Equals(a))
|
||||
c := types.String("c")
|
||||
dsy, err = store.CommitValue(context.Background(), dsy, c)
|
||||
assert.Error(err)
|
||||
assert.True(dsy.Head().Get(ValueField).Equals(types.Format_7_18, b))
|
||||
assert.True(dsy.Head().Get(ValueField).Equals(b))
|
||||
// Commit failed, but dsy now has latest head, so we should be able to just try again.
|
||||
// dsy: |b| -> |c|
|
||||
dsy, err = store.CommitValue(context.Background(), dsy, c)
|
||||
assert.NoError(err)
|
||||
assert.True(dsy.Head().Get(ValueField).Equals(types.Format_7_18, c))
|
||||
assert.True(dsy.Head().Get(ValueField).Equals(c))
|
||||
}
|
||||
|
||||
func TestIdValidation(t *testing.T) {
|
||||
|
||||
@@ -159,7 +159,7 @@ func (suite *PullSuite) TestPullEverything() {
|
||||
|
||||
v := suite.sink.ReadValue(context.Background(), sourceRef.TargetHash()).(types.Struct)
|
||||
suite.NotNil(v)
|
||||
suite.True(l.Equals(types.Format_7_18, v.Get(ValueField)))
|
||||
suite.True(l.Equals(v.Get(ValueField)))
|
||||
}
|
||||
|
||||
// Source: -6-> C3(L5) -1-> N
|
||||
@@ -202,7 +202,7 @@ func (suite *PullSuite) TestPullMultiGeneration() {
|
||||
|
||||
v := suite.sink.ReadValue(context.Background(), sourceRef.TargetHash()).(types.Struct)
|
||||
suite.NotNil(v)
|
||||
suite.True(srcL.Equals(types.Format_7_18, v.Get(ValueField)))
|
||||
suite.True(srcL.Equals(v.Get(ValueField)))
|
||||
}
|
||||
|
||||
// Source: -6-> C2(L5) -1-> N
|
||||
@@ -248,7 +248,7 @@ func (suite *PullSuite) TestPullDivergentHistory() {
|
||||
|
||||
v := suite.sink.ReadValue(context.Background(), sourceRef.TargetHash()).(types.Struct)
|
||||
suite.NotNil(v)
|
||||
suite.True(srcL.Equals(types.Format_7_18, v.Get(ValueField)))
|
||||
suite.True(srcL.Equals(v.Get(ValueField)))
|
||||
}
|
||||
|
||||
// Source: -6-> C2(L4) -1-> N
|
||||
@@ -290,7 +290,7 @@ func (suite *PullSuite) TestPullUpdates() {
|
||||
|
||||
v := suite.sink.ReadValue(context.Background(), sourceRef.TargetHash()).(types.Struct)
|
||||
suite.NotNil(v)
|
||||
suite.True(srcL.Equals(types.Format_7_18, v.Get(ValueField)))
|
||||
suite.True(srcL.Equals(v.Get(ValueField)))
|
||||
}
|
||||
|
||||
func (suite *PullSuite) commitToSource(v types.Value, p types.Set) types.Ref {
|
||||
|
||||
@@ -138,7 +138,7 @@ func getPatch(g1, g2 types.Value) Patch {
|
||||
func checkApplyPatch(assert *assert.Assertions, g1, expectedG2 types.Value, k1, k2 string) {
|
||||
patch := getPatch(g1, expectedG2)
|
||||
g2 := Apply(context.Background(), types.Format_7_18, g1, patch)
|
||||
assert.True(expectedG2.Equals(types.Format_7_18, g2), "failed to apply diffs for k1: %s and k2: %s", k1, k2)
|
||||
assert.True(expectedG2.Equals(g2), "failed to apply diffs for k1: %s and k2: %s", k1, k2)
|
||||
}
|
||||
|
||||
func TestPatches(t *testing.T) {
|
||||
@@ -185,7 +185,7 @@ func TestUpdateNode(t *testing.T) {
|
||||
se := &stackElem{path: []types.PathPart{pp}, pathPart: pp, changeType: types.DiffChangeModified, oldValue: ov, newValue: nv}
|
||||
updated := stack.updateNode(context.Background(), types.Format_7_18, se, parent)
|
||||
testVal := f(updated)
|
||||
assert.True(exp.Equals(types.Format_7_18, testVal), "%s != %s", nv, testVal)
|
||||
assert.True(exp.Equals(testVal), "%s != %s", nv, testVal)
|
||||
}
|
||||
|
||||
var pp types.PathPart
|
||||
@@ -250,7 +250,7 @@ func checkApplyDiffs(a *assert.Assertions, n1, n2 types.Value, leftRight bool) {
|
||||
}
|
||||
|
||||
res := Apply(context.Background(), types.Format_7_18, n1, difs)
|
||||
a.True(n2.Equals(types.Format_7_18, res))
|
||||
a.True(n2.Equals(res))
|
||||
}
|
||||
|
||||
func tryApplyDiff(a *assert.Assertions, a1, a2 interface{}) {
|
||||
|
||||
@@ -89,7 +89,7 @@ func Diff(ctx context.Context, format *types.Format, v1, v2 types.Value, dChan c
|
||||
}
|
||||
|
||||
d := differ{diffChan: dChan, stopChan: stopChan, leftRight: leftRight, shouldDescend: descFunc}
|
||||
if !v1.Equals(format, v2) {
|
||||
if !v1.Equals(v2) {
|
||||
if !d.shouldDescend(v1, v2) {
|
||||
d.sendDiff(Difference{Path: nil, ChangeType: types.DiffChangeModified, OldValue: v1, NewValue: v2})
|
||||
} else {
|
||||
|
||||
@@ -78,7 +78,7 @@ func indexPathCompare(format *types.Format, pp types.IndexPath, o types.PathPart
|
||||
case types.FieldPath:
|
||||
return 1
|
||||
case types.IndexPath:
|
||||
if pp.Index.Equals(format, opp.Index) {
|
||||
if pp.Index.Equals(opp.Index) {
|
||||
if pp.IntoKey == opp.IntoKey {
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ type diffSummaryProgress struct {
|
||||
}
|
||||
|
||||
func diffSummary(ctx context.Context, format *types.Format, ch chan diffSummaryProgress, v1, v2 types.Value) {
|
||||
if !v1.Equals(format, v2) {
|
||||
if !v1.Equals(v2) {
|
||||
if ShouldDescend(v1, v2) {
|
||||
switch v1.Kind() {
|
||||
case types.ListKind:
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestDecode(tt *testing.T) {
|
||||
err := Unmarshal(context.Background(), types.Format_7_18, v, p.Interface())
|
||||
assert.NoError(err)
|
||||
if expectedValue, ok := expected.(types.Value); ok {
|
||||
assert.True(expectedValue.Equals(types.Format_7_18, p.Elem().Interface().(types.Value)))
|
||||
assert.True(expectedValue.Equals(p.Elem().Interface().(types.Value)))
|
||||
} else {
|
||||
assert.Equal(expected, p.Elem().Interface())
|
||||
}
|
||||
@@ -41,7 +41,7 @@ func TestDecode(tt *testing.T) {
|
||||
var v2 types.Value
|
||||
err = Unmarshal(context.Background(), types.Format_7_18, v, &v2)
|
||||
assert.NoError(err)
|
||||
assert.True(v.Equals(types.Format_7_18, v2))
|
||||
assert.True(v.Equals(v2))
|
||||
}
|
||||
|
||||
for _, n := range []float32{0, 42, 3.14159265359, math.MaxFloat32} {
|
||||
@@ -241,7 +241,7 @@ func TestDecodeStructWithNomsValue(t *testing.T) {
|
||||
assert.IsType(t, T2{}, t2)
|
||||
assert.Equal(t, TestStruct{false, 1, "bye"}, t2.Abc)
|
||||
// TODO(binformat)
|
||||
assert.True(t, t2.Def.Equals(types.Format_7_18, types.NewList(context.Background(), vs, types.Float(42))))
|
||||
assert.True(t, t2.Def.Equals(types.NewList(context.Background(), vs, types.Float(42))))
|
||||
}
|
||||
|
||||
func TestDecodeNilPointer(t *testing.T) {
|
||||
@@ -1132,7 +1132,7 @@ func TestDecodeOriginal(t *testing.T) {
|
||||
var actual S
|
||||
err := Unmarshal(context.Background(), types.Format_7_18, input, &actual)
|
||||
assert.NoError(err)
|
||||
assert.True(expected.Bar.Equals(types.Format_7_18, actual.Bar))
|
||||
assert.True(expected.Bar.Equals(actual.Bar))
|
||||
}
|
||||
|
||||
func TestDecodeOriginalReceiveTypeError(t *testing.T) {
|
||||
|
||||
@@ -25,12 +25,12 @@ func TestEncode(tt *testing.T) {
|
||||
t := func(exp types.Value, v interface{}) {
|
||||
actual, err := Marshal(context.Background(), vs, v)
|
||||
assert.NoError(tt, err)
|
||||
assert.True(tt, exp.Equals(types.Format_7_18, actual))
|
||||
assert.True(tt, exp.Equals(actual))
|
||||
|
||||
// Encode again for fallthrough
|
||||
actual2, err := Marshal(context.Background(), vs, actual)
|
||||
assert.NoError(tt, err)
|
||||
assert.True(tt, exp.Equals(types.Format_7_18, actual2))
|
||||
assert.True(tt, exp.Equals(actual2))
|
||||
}
|
||||
|
||||
for _, n := range []float32{0, 42, 3.14159265359, math.MaxFloat32} {
|
||||
@@ -189,7 +189,7 @@ func TestEncodeEmbeddedStructSkip(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "TestStruct", types.StructData{
|
||||
"y": types.Float(2),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeEmbeddedStructWithName(t *testing.T) {
|
||||
@@ -213,7 +213,7 @@ func TestEncodeEmbeddedStructWithName(t *testing.T) {
|
||||
"x": types.Float(1),
|
||||
}),
|
||||
"y": types.Float(2),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeEmbeddedStruct(t *testing.T) {
|
||||
@@ -233,7 +233,7 @@ func TestEncodeEmbeddedStruct(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "TestStruct", types.StructData{
|
||||
"x": types.Float(1),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
|
||||
type TestOuter struct {
|
||||
A int
|
||||
@@ -247,7 +247,7 @@ func TestEncodeEmbeddedStruct(t *testing.T) {
|
||||
"a": types.Float(0),
|
||||
"b": types.Float(2),
|
||||
"x": types.Float(1),
|
||||
}).Equals(types.Format_7_18, v2))
|
||||
}).Equals(v2))
|
||||
}
|
||||
|
||||
func TestEncodeEmbeddedStructOriginal(t *testing.T) {
|
||||
@@ -275,7 +275,7 @@ func TestEncodeEmbeddedStructOriginal(t *testing.T) {
|
||||
assert.True(types.NewStruct(types.Format_7_18, "TestStruct", types.StructData{
|
||||
"b": types.Bool(true),
|
||||
"x": types.Float(1),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeNonExportedField(t *testing.T) {
|
||||
@@ -300,7 +300,7 @@ func TestEncodeTaggingSkip(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S", types.StructData{
|
||||
"def": types.Bool(true),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeNamedFields(t *testing.T) {
|
||||
@@ -321,7 +321,7 @@ func TestEncodeNamedFields(t *testing.T) {
|
||||
"a": types.Float(42),
|
||||
"B": types.Bool(true),
|
||||
"ccc": types.String("Hi"),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeInvalidNamedFields(t *testing.T) {
|
||||
@@ -386,7 +386,7 @@ func TestEncodeOmitEmpty(t *testing.T) {
|
||||
"uint64": types.Float(1),
|
||||
"float32": types.Float(1),
|
||||
"float64": types.Float(1),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
|
||||
s2 := S{
|
||||
String: "",
|
||||
@@ -406,7 +406,7 @@ func TestEncodeOmitEmpty(t *testing.T) {
|
||||
}
|
||||
v2, err := Marshal(context.Background(), vs, s2)
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S", types.StructData{}).Equals(types.Format_7_18, v2))
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S", types.StructData{}).Equals(v2))
|
||||
|
||||
type S2 struct {
|
||||
Slice []int `noms:",omitempty"`
|
||||
@@ -422,7 +422,7 @@ func TestEncodeOmitEmpty(t *testing.T) {
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S2", types.StructData{
|
||||
"slice": types.NewList(context.Background(), vs, types.Float(0)),
|
||||
"map": types.NewMap(context.Background(), vs, types.Float(0), types.Float(0)),
|
||||
}).Equals(types.Format_7_18, v3))
|
||||
}).Equals(v3))
|
||||
|
||||
s4 := S2{
|
||||
Slice: []int{},
|
||||
@@ -430,7 +430,7 @@ func TestEncodeOmitEmpty(t *testing.T) {
|
||||
}
|
||||
v4, err := Marshal(context.Background(), vs, s4)
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S2", types.StructData{}).Equals(types.Format_7_18, v4))
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S2", types.StructData{}).Equals(v4))
|
||||
|
||||
s5 := S2{
|
||||
Slice: nil,
|
||||
@@ -438,7 +438,7 @@ func TestEncodeOmitEmpty(t *testing.T) {
|
||||
}
|
||||
v5, err := Marshal(context.Background(), vs, s5)
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S2", types.StructData{}).Equals(types.Format_7_18, v5))
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S2", types.StructData{}).Equals(v5))
|
||||
|
||||
type S3 struct {
|
||||
List types.List `noms:",omitempty"`
|
||||
@@ -453,7 +453,7 @@ func TestEncodeOmitEmpty(t *testing.T) {
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S3", types.StructData{
|
||||
"list": types.NewList(context.Background(), vs),
|
||||
"value": types.Float(0),
|
||||
}).Equals(types.Format_7_18, v6))
|
||||
}).Equals(v6))
|
||||
|
||||
s7 := S3{
|
||||
List: types.List{},
|
||||
@@ -461,7 +461,7 @@ func TestEncodeOmitEmpty(t *testing.T) {
|
||||
}
|
||||
v7, err := Marshal(context.Background(), vs, s7)
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S3", types.StructData{}).Equals(types.Format_7_18, v7))
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S3", types.StructData{}).Equals(v7))
|
||||
|
||||
// Both name and omitempty
|
||||
type S4 struct {
|
||||
@@ -474,14 +474,14 @@ func TestEncodeOmitEmpty(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S4", types.StructData{
|
||||
"y": types.Float(1),
|
||||
}).Equals(types.Format_7_18, v8))
|
||||
}).Equals(v8))
|
||||
|
||||
s9 := S4{
|
||||
X: 0,
|
||||
}
|
||||
v9, err := Marshal(context.Background(), vs, s9)
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S4", types.StructData{}).Equals(types.Format_7_18, v9))
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S4", types.StructData{}).Equals(v9))
|
||||
}
|
||||
|
||||
func ExampleMarshal() {
|
||||
@@ -510,7 +510,7 @@ func TestEncodeSlice(t *testing.T) {
|
||||
|
||||
v, err := Marshal(context.Background(), vs, []string{"a", "b", "c"})
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewList(context.Background(), vs, types.String("a"), types.String("b"), types.String("c")).Equals(types.Format_7_18, v))
|
||||
assert.True(types.NewList(context.Background(), vs, types.String("a"), types.String("b"), types.String("c")).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeArray(t *testing.T) {
|
||||
@@ -521,7 +521,7 @@ func TestEncodeArray(t *testing.T) {
|
||||
|
||||
v, err := Marshal(context.Background(), vs, [3]int{1, 2, 3})
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewList(context.Background(), vs, types.Float(1), types.Float(2), types.Float(3)).Equals(types.Format_7_18, v))
|
||||
assert.True(types.NewList(context.Background(), vs, types.Float(1), types.Float(2), types.Float(3)).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeStructWithSlice(t *testing.T) {
|
||||
@@ -537,7 +537,7 @@ func TestEncodeStructWithSlice(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S", types.StructData{
|
||||
"list": types.NewList(context.Background(), vs, types.Float(1), types.Float(2), types.Float(3)),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeStructWithArrayOfNomsValue(t *testing.T) {
|
||||
@@ -553,7 +553,7 @@ func TestEncodeStructWithArrayOfNomsValue(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S", types.StructData{
|
||||
"list": types.NewList(context.Background(), vs, types.NewSet(context.Background(), vs, types.Bool(true))),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeNomsTypePtr(t *testing.T) {
|
||||
@@ -612,7 +612,7 @@ func TestEncodeRecursive(t *testing.T) {
|
||||
Type: types.FloaTType,
|
||||
},
|
||||
)
|
||||
assert.True(typ.Equals(types.Format_7_18, types.TypeOf(v)))
|
||||
assert.True(typ.Equals(types.TypeOf(v)))
|
||||
|
||||
assert.True(types.NewStruct(types.Format_7_18, "Node", types.StructData{
|
||||
"children": types.NewList(context.Background(),
|
||||
@@ -627,7 +627,7 @@ func TestEncodeRecursive(t *testing.T) {
|
||||
}),
|
||||
),
|
||||
"value": types.Float(1),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeMap(t *testing.T) {
|
||||
@@ -642,7 +642,7 @@ func TestEncodeMap(t *testing.T) {
|
||||
vs,
|
||||
types.String("a"), types.Float(1),
|
||||
types.String("b"), types.Float(2),
|
||||
types.String("c"), types.Float(3)).Equals(types.Format_7_18, v))
|
||||
types.String("c"), types.Float(3)).Equals(v))
|
||||
|
||||
type S struct {
|
||||
N string
|
||||
@@ -652,15 +652,15 @@ func TestEncodeMap(t *testing.T) {
|
||||
assert.True(types.NewMap(context.Background(),
|
||||
vs,
|
||||
types.NewStruct(types.Format_7_18, "S", types.StructData{"n": types.String("Yes")}), types.Bool(true),
|
||||
types.NewStruct(types.Format_7_18, "S", types.StructData{"n": types.String("No")}), types.Bool(false)).Equals(types.Format_7_18, v))
|
||||
types.NewStruct(types.Format_7_18, "S", types.StructData{"n": types.String("No")}), types.Bool(false)).Equals(v))
|
||||
|
||||
v, err = Marshal(context.Background(), vs, map[string]int(nil))
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewMap(context.Background(), vs).Equals(types.Format_7_18, v))
|
||||
assert.True(types.NewMap(context.Background(), vs).Equals(v))
|
||||
|
||||
v, err = Marshal(context.Background(), vs, map[string]int{})
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewMap(context.Background(), vs).Equals(types.Format_7_18, v))
|
||||
assert.True(types.NewMap(context.Background(), vs).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeInterface(t *testing.T) {
|
||||
@@ -672,7 +672,7 @@ func TestEncodeInterface(t *testing.T) {
|
||||
var i interface{} = []string{"a", "b"}
|
||||
v, err := Marshal(context.Background(), vs, i)
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewList(context.Background(), vs, types.String("a"), types.String("b")).Equals(types.Format_7_18, v))
|
||||
assert.True(types.NewList(context.Background(), vs, types.String("a"), types.String("b")).Equals(v))
|
||||
|
||||
i = map[interface{}]interface{}{"a": true, struct{ Name string }{"b"}: 42}
|
||||
v, err = Marshal(context.Background(), vs, i)
|
||||
@@ -681,7 +681,7 @@ func TestEncodeInterface(t *testing.T) {
|
||||
vs,
|
||||
types.String("a"), types.Bool(true),
|
||||
types.NewStruct(types.Format_7_18, "", types.StructData{"name": types.String("b")}), types.Float(42),
|
||||
).Equals(types.Format_7_18, v))
|
||||
).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeSet(t *testing.T) {
|
||||
@@ -791,7 +791,7 @@ func TestEncodeOpt(t *testing.T) {
|
||||
|
||||
for _, t := range tc {
|
||||
r, err := MarshalOpt(context.Background(), vs, t.in, t.opt)
|
||||
assert.True(t.wantValue.Equals(types.Format_7_18, r))
|
||||
assert.True(t.wantValue.Equals(r))
|
||||
assert.Nil(err)
|
||||
}
|
||||
}
|
||||
@@ -823,11 +823,11 @@ func TestEncodeSetWithTags(t *testing.T) {
|
||||
|
||||
foo, ok := s.Get("foo").(types.Set)
|
||||
assert.True(ok)
|
||||
assert.True(types.NewSet(context.Background(), vs, types.Float(0), types.Float(1)).Equals(types.Format_7_18, foo))
|
||||
assert.True(types.NewSet(context.Background(), vs, types.Float(0), types.Float(1)).Equals(foo))
|
||||
|
||||
bar, ok := s.Get("bar").(types.Set)
|
||||
assert.True(ok)
|
||||
assert.True(types.NewSet(context.Background(), vs, types.Float(2), types.Float(3)).Equals(types.Format_7_18, bar))
|
||||
assert.True(types.NewSet(context.Background(), vs, types.Float(2), types.Float(3)).Equals(bar))
|
||||
}
|
||||
|
||||
func TestInvalidTag(t *testing.T) {
|
||||
@@ -856,7 +856,7 @@ func TestEncodeCanSkipUnexportedField(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "S", types.StructData{
|
||||
"abc": types.Float(42),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
}
|
||||
|
||||
func TestEncodeOriginal(t *testing.T) {
|
||||
@@ -880,21 +880,21 @@ func TestEncodeOriginal(t *testing.T) {
|
||||
err = Unmarshal(context.Background(), types.Format_7_18, orig, &s)
|
||||
assert.NoError(err)
|
||||
s.Foo = 43
|
||||
assert.True(MustMarshal(context.Background(), vs, s).Equals(types.Format_7_18, orig.Set("foo", types.Float(43))))
|
||||
assert.True(MustMarshal(context.Background(), vs, s).Equals(orig.Set("foo", types.Float(43))))
|
||||
|
||||
// New field extends old struct
|
||||
orig = types.NewStruct(types.Format_7_18, "S", types.StructData{})
|
||||
err = Unmarshal(context.Background(), types.Format_7_18, orig, &s)
|
||||
assert.NoError(err)
|
||||
s.Foo = 43
|
||||
assert.True(MustMarshal(context.Background(), vs, s).Equals(types.Format_7_18, orig.Set("foo", types.Float(43))))
|
||||
assert.True(MustMarshal(context.Background(), vs, s).Equals(orig.Set("foo", types.Float(43))))
|
||||
|
||||
// Old struct name always used
|
||||
orig = types.NewStruct(types.Format_7_18, "Q", types.StructData{})
|
||||
err = Unmarshal(context.Background(), types.Format_7_18, orig, &s)
|
||||
assert.NoError(err)
|
||||
s.Foo = 43
|
||||
assert.True(MustMarshal(context.Background(), vs, s).Equals(types.Format_7_18, orig.Set("foo", types.Float(43))))
|
||||
assert.True(MustMarshal(context.Background(), vs, s).Equals(orig.Set("foo", types.Float(43))))
|
||||
|
||||
// Field type of base are preserved
|
||||
orig = types.NewStruct(types.Format_7_18, "S", types.StructData{
|
||||
@@ -904,18 +904,18 @@ func TestEncodeOriginal(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
s.Foo = 43
|
||||
out := MustMarshal(context.Background(), vs, s)
|
||||
assert.True(out.Equals(types.Format_7_18, orig.Set("foo", types.Float(43))))
|
||||
assert.True(out.Equals(orig.Set("foo", types.Float(43))))
|
||||
|
||||
st2 := types.MakeStructTypeFromFields("S", types.FieldMap{
|
||||
"foo": types.FloaTType,
|
||||
})
|
||||
assert.True(types.TypeOf(out).Equals(types.Format_7_18, st2))
|
||||
assert.True(types.TypeOf(out).Equals(st2))
|
||||
|
||||
// It's OK to have an empty original field
|
||||
s = S{
|
||||
Foo: 42,
|
||||
}
|
||||
assert.True(MustMarshal(context.Background(), vs, s).Equals(types.Format_7_18,
|
||||
assert.True(MustMarshal(context.Background(), vs, s).Equals(
|
||||
types.NewStruct(types.Format_7_18, "S", types.StructData{"foo": types.Float(float64(42))})))
|
||||
}
|
||||
|
||||
@@ -939,7 +939,7 @@ func TestNomsTypes(t *testing.T) {
|
||||
String: types.String("hi"),
|
||||
Type: types.FloaTType,
|
||||
}
|
||||
assert.True(MustMarshal(context.Background(), vs, s).Equals(types.Format_7_18,
|
||||
assert.True(MustMarshal(context.Background(), vs, s).Equals(
|
||||
types.NewStruct(types.Format_7_18, "S", types.StructData{
|
||||
"blob": types.NewBlob(context.Background(), vs),
|
||||
"bool": types.Bool(true),
|
||||
@@ -1005,7 +1005,7 @@ func TestMarshalerPrimitiveMapType(t *testing.T) {
|
||||
"b": "bar",
|
||||
})
|
||||
v := MustMarshal(context.Background(), vs, u)
|
||||
assert.True(types.NewSet(context.Background(), vs, types.String("a,foo"), types.String("b,bar")).Equals(types.Format_7_18, v))
|
||||
assert.True(types.NewSet(context.Background(), vs, types.String("a,foo"), types.String("b,bar")).Equals(v))
|
||||
}
|
||||
|
||||
type primitiveStructType struct {
|
||||
@@ -1108,7 +1108,7 @@ func TestMarshalerComplexStructType(t *testing.T) {
|
||||
"pmap": types.NewSet(context.Background(), vs, types.String("c,123"), types.String("d,456")),
|
||||
"pstruct": types.Float(30),
|
||||
"b": types.String(s),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
}
|
||||
|
||||
type returnsMarshalerError struct {
|
||||
@@ -1168,7 +1168,7 @@ func TestMarshalStructName(t *testing.T) {
|
||||
v := MustMarshal(context.Background(), vs, ts)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "A", types.StructData{
|
||||
"x": types.Float(1),
|
||||
}).Equals(types.Format_7_18, v), types.EncodedValue(context.Background(), types.Format_7_18, v))
|
||||
}).Equals(v), types.EncodedValue(context.Background(), types.Format_7_18, v))
|
||||
}
|
||||
|
||||
type TestStructWithNameImpl2 struct {
|
||||
@@ -1190,5 +1190,5 @@ func TestMarshalStructName2(t *testing.T) {
|
||||
v := MustMarshal(context.Background(), vs, ts)
|
||||
assert.True(types.NewStruct(types.Format_7_18, "", types.StructData{
|
||||
"x": types.Float(1),
|
||||
}).Equals(types.Format_7_18, v), types.EncodedValue(context.Background(), types.Format_7_18, v))
|
||||
}).Equals(v), types.EncodedValue(context.Background(), types.Format_7_18, v))
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestMarshalTypeType(tt *testing.T) {
|
||||
actual, err := MarshalType(types.Format_7_18, p.Interface())
|
||||
assert.NoError(tt, err)
|
||||
assert.NotNil(tt, actual, "%#v", p.Interface())
|
||||
assert.True(tt, exp.Equals(types.Format_7_18, actual))
|
||||
assert.True(tt, exp.Equals(actual))
|
||||
}
|
||||
|
||||
t(types.FloaTType, float32(0))
|
||||
@@ -132,7 +132,7 @@ func TestMarshalTypeEmbeddedStruct(t *testing.T) {
|
||||
assert.True(types.MakeStructTypeFromFields("TestStruct", types.FieldMap{
|
||||
"a": types.FloaTType,
|
||||
"b": types.BoolType,
|
||||
}).Equals(types.Format_7_18, typ))
|
||||
}).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeEmbeddedStructSkip(t *testing.T) {
|
||||
@@ -151,7 +151,7 @@ func TestMarshalTypeEmbeddedStructSkip(t *testing.T) {
|
||||
|
||||
assert.True(types.MakeStructTypeFromFields("TestStruct", types.FieldMap{
|
||||
"a": types.FloaTType,
|
||||
}).Equals(types.Format_7_18, typ))
|
||||
}).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeEmbeddedStructNamed(t *testing.T) {
|
||||
@@ -173,7 +173,7 @@ func TestMarshalTypeEmbeddedStructNamed(t *testing.T) {
|
||||
"em": types.MakeStructTypeFromFields("EmbeddedStruct", types.FieldMap{
|
||||
"b": types.BoolType,
|
||||
}),
|
||||
}).Equals(types.Format_7_18, typ))
|
||||
}).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeEncodeNonExportedField(t *testing.T) {
|
||||
@@ -195,7 +195,7 @@ func TestMarshalTypeEncodeTaggingSkip(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(types.MakeStructTypeFromFields("S", types.FieldMap{
|
||||
"def": types.BoolType,
|
||||
}).Equals(types.Format_7_18, typ))
|
||||
}).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeNamedFields(t *testing.T) {
|
||||
@@ -213,7 +213,7 @@ func TestMarshalTypeNamedFields(t *testing.T) {
|
||||
"a": types.FloaTType,
|
||||
"B": types.BoolType,
|
||||
"ccc": types.StringType,
|
||||
}).Equals(types.Format_7_18, typ))
|
||||
}).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeInvalidNamedFields(t *testing.T) {
|
||||
@@ -233,7 +233,7 @@ func TestMarshalTypeOmitEmpty(t *testing.T) {
|
||||
var s S
|
||||
typ, err := MarshalType(types.Format_7_18, s)
|
||||
assert.NoError(err)
|
||||
assert.True(types.MakeStructType("S", types.StructField{"string", types.StringType, true}).Equals(types.Format_7_18, typ))
|
||||
assert.True(types.MakeStructType("S", types.StructField{"string", types.StringType, true}).Equals(typ))
|
||||
}
|
||||
|
||||
func ExampleMarshalType() {
|
||||
@@ -262,7 +262,7 @@ func TestMarshalTypeSlice(t *testing.T) {
|
||||
s := []string{"a", "b", "c"}
|
||||
typ, err := MarshalType(types.Format_7_18, s)
|
||||
assert.NoError(err)
|
||||
assert.True(types.MakeListType(types.StringType).Equals(types.Format_7_18, typ))
|
||||
assert.True(types.MakeListType(types.StringType).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeArray(t *testing.T) {
|
||||
@@ -271,7 +271,7 @@ func TestMarshalTypeArray(t *testing.T) {
|
||||
a := [3]int{1, 2, 3}
|
||||
typ, err := MarshalType(types.Format_7_18, a)
|
||||
assert.NoError(err)
|
||||
assert.True(types.MakeListType(types.FloaTType).Equals(types.Format_7_18, typ))
|
||||
assert.True(types.MakeListType(types.FloaTType).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeStructWithSlice(t *testing.T) {
|
||||
@@ -285,7 +285,7 @@ func TestMarshalTypeStructWithSlice(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(types.MakeStructTypeFromFields("S", types.FieldMap{
|
||||
"list": types.MakeListType(types.FloaTType),
|
||||
}).Equals(types.Format_7_18, typ))
|
||||
}).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeRecursive(t *testing.T) {
|
||||
@@ -309,7 +309,7 @@ func TestMarshalTypeRecursive(t *testing.T) {
|
||||
Type: types.FloaTType,
|
||||
},
|
||||
)
|
||||
assert.True(typ2.Equals(types.Format_7_18, typ))
|
||||
assert.True(typ2.Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeMap(t *testing.T) {
|
||||
@@ -318,7 +318,7 @@ func TestMarshalTypeMap(t *testing.T) {
|
||||
var m map[string]int
|
||||
typ, err := MarshalType(types.Format_7_18, m)
|
||||
assert.NoError(err)
|
||||
assert.True(types.MakeMapType(types.StringType, types.FloaTType).Equals(types.Format_7_18, typ))
|
||||
assert.True(types.MakeMapType(types.StringType, types.FloaTType).Equals(typ))
|
||||
|
||||
type S struct {
|
||||
N string
|
||||
@@ -331,7 +331,7 @@ func TestMarshalTypeMap(t *testing.T) {
|
||||
types.MakeStructTypeFromFields("S", types.FieldMap{
|
||||
"n": types.StringType,
|
||||
}),
|
||||
types.BoolType).Equals(types.Format_7_18, typ))
|
||||
types.BoolType).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeSet(t *testing.T) {
|
||||
@@ -362,7 +362,7 @@ func TestMarshalTypeSet(t *testing.T) {
|
||||
"f": types.MakeMapType(types.StringType, types.FloaTType),
|
||||
"g": types.MakeSetType(types.FloaTType),
|
||||
"h": types.StringType,
|
||||
}).Equals(types.Format_7_18, typ))
|
||||
}).Equals(typ))
|
||||
}
|
||||
|
||||
func TestEncodeTypeOpt(t *testing.T) {
|
||||
@@ -397,7 +397,7 @@ func TestEncodeTypeOpt(t *testing.T) {
|
||||
|
||||
for _, t := range tc {
|
||||
r, err := MarshalTypeOpt(types.Format_7_18, t.in, t.opt)
|
||||
assert.True(t.wantType.Equals(types.Format_7_18, r))
|
||||
assert.True(t.wantType.Equals(r))
|
||||
assert.Nil(err)
|
||||
}
|
||||
}
|
||||
@@ -418,7 +418,7 @@ func TestMarshalTypeSetWithTags(t *testing.T) {
|
||||
types.StructField{"foo", types.MakeSetType(types.FloaTType), false},
|
||||
types.StructField{"b", types.MakeSetType(types.FloaTType), true},
|
||||
types.StructField{"bar", types.MakeSetType(types.FloaTType), true},
|
||||
).Equals(types.Format_7_18, typ))
|
||||
).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeInvalidTag(t *testing.T) {
|
||||
@@ -446,7 +446,7 @@ func TestMarshalTypeCanSkipUnexportedField(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(types.MakeStructTypeFromFields("S", types.FieldMap{
|
||||
"abc": types.FloaTType,
|
||||
}).Equals(types.Format_7_18, typ))
|
||||
}).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeOriginal(t *testing.T) {
|
||||
@@ -462,7 +462,7 @@ func TestMarshalTypeOriginal(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(types.MakeStructType("S",
|
||||
types.StructField{"foo", types.FloaTType, true},
|
||||
).Equals(types.Format_7_18, typ))
|
||||
).Equals(typ))
|
||||
}
|
||||
|
||||
func TestMarshalTypeNomsTypes(t *testing.T) {
|
||||
@@ -476,7 +476,7 @@ func TestMarshalTypeNomsTypes(t *testing.T) {
|
||||
Type *types.Type
|
||||
}
|
||||
var s S
|
||||
assert.True(MustMarshalType(types.Format_7_18, s).Equals(types.Format_7_18,
|
||||
assert.True(MustMarshalType(types.Format_7_18, s).Equals(
|
||||
types.MakeStructTypeFromFields("S", types.FieldMap{
|
||||
"blob": types.BlobType,
|
||||
"bool": types.BoolType,
|
||||
@@ -588,7 +588,7 @@ func TestMarshalTypeStructName(t *testing.T) {
|
||||
|
||||
var ts TestStructWithNameImpl
|
||||
typ := MustMarshalType(types.Format_7_18, ts)
|
||||
assert.True(types.MakeStructType("A", types.StructField{"x", types.FloaTType, false}).Equals(types.Format_7_18, typ), typ.Describe(context.Background(), types.Format_7_18))
|
||||
assert.True(types.MakeStructType("A", types.StructField{"x", types.FloaTType, false}).Equals(typ), typ.Describe(context.Background(), types.Format_7_18))
|
||||
}
|
||||
|
||||
func TestMarshalTypeStructName2(t *testing.T) {
|
||||
@@ -596,7 +596,7 @@ func TestMarshalTypeStructName2(t *testing.T) {
|
||||
|
||||
var ts TestStructWithNameImpl2
|
||||
typ := MustMarshalType(types.Format_7_18, ts)
|
||||
assert.True(types.MakeStructType("", types.StructField{"x", types.FloaTType, false}).Equals(types.Format_7_18, typ), typ.Describe(context.Background(), types.Format_7_18))
|
||||
assert.True(types.MakeStructType("", types.StructField{"x", types.FloaTType, false}).Equals(typ), typ.Describe(context.Background(), types.Format_7_18))
|
||||
}
|
||||
|
||||
type OutPhoto struct {
|
||||
@@ -621,5 +621,5 @@ func TestMarshalTypeOutface(t *testing.T) {
|
||||
}>,
|
||||
someOtherFacesSet: Set<Cycle<Face>>,
|
||||
}`)
|
||||
assert.True(t, typ.Equals(types.Format_7_18, expectedType))
|
||||
assert.True(t, typ.Equals(expectedType))
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ func (s *ThreeWayKeyValMergeSuite) TestThreeWayMerge_CustomMerge() {
|
||||
merged, err := ThreeWay(context.Background(), s.create(a), s.create(b), s.create(p), s.vs, resolve, nil)
|
||||
if s.NoError(err) {
|
||||
expected := s.create(exp)
|
||||
s.True(expected.Equals(types.Format_7_18, merged), "%s != %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, merged))
|
||||
s.True(expected.Equals(merged), "%s != %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, merged))
|
||||
}
|
||||
if s.Len(conflictPaths, len(expectedConflictPaths), "Wrong number of conflicts!") {
|
||||
for i := 0; i < len(conflictPaths); i++ {
|
||||
@@ -187,7 +187,7 @@ func (s *ThreeWayKeyValMergeSuite) TestThreeWayMerge_MergeOurs() {
|
||||
merged, err := ThreeWay(context.Background(), s.create(a), s.create(b), s.create(p), s.vs, Ours, nil)
|
||||
if s.NoError(err) {
|
||||
expected := s.create(exp)
|
||||
s.True(expected.Equals(types.Format_7_18, merged), "%s != %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, merged))
|
||||
s.True(expected.Equals(merged), "%s != %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, merged))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ func (s *ThreeWayKeyValMergeSuite) TestThreeWayMerge_MergeTheirs() {
|
||||
merged, err := ThreeWay(context.Background(), s.create(a), s.create(b), s.create(p), s.vs, Theirs, nil)
|
||||
if s.NoError(err) {
|
||||
expected := s.create(exp)
|
||||
s.True(expected.Equals(types.Format_7_18, merged), "%s != %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, merged))
|
||||
s.True(expected.Equals(merged), "%s != %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, merged))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ func canMerge(ctx context.Context, format *types.Format, a, b types.List, aSplic
|
||||
aIter, bIter := a.IteratorAt(ctx, aSplice.SpFrom), b.IteratorAt(ctx, bSplice.SpFrom)
|
||||
for count := uint64(0); count < aSplice.SpAdded; count++ {
|
||||
aVal, bVal := aIter.Next(ctx), bIter.Next(ctx)
|
||||
if aVal == nil || bVal == nil || !aVal.Equals(format, bVal) {
|
||||
if aVal == nil || bVal == nil || !aVal.Equals(bVal) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func (m *merger) threeWayOrderedSequenceMerge(ctx context.Context, format *types
|
||||
bChange = types.ValueChanged{}
|
||||
continue
|
||||
}
|
||||
if !aChange.Key.Equals(format, bChange.Key) {
|
||||
if !aChange.Key.Equals(bChange.Key) {
|
||||
d.Panic("Diffs have skewed!") // Sanity check.
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ func (m *merger) mergeChanges(ctx context.Context, format *types.Format, aChange
|
||||
return change, nil, newMergeConflict("Conflict:\n%s\nvs\n%s\n", describeChange(format, aChange), describeChange(format, bChange))
|
||||
}
|
||||
|
||||
if aChange.ChangeType == types.DiffChangeRemoved || aValue.Equals(format, bValue) {
|
||||
if aChange.ChangeType == types.DiffChangeRemoved || aValue.Equals(bValue) {
|
||||
// If both diffs generated a remove, or if the new value is the same in both, merge is fine.
|
||||
return aChange, aValue, nil
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func (s *ThreeWayMergeSuite) tryThreeWayMerge(a, b, p, exp seq) {
|
||||
merged, err := ThreeWay(context.Background(), s.create(a), s.create(b), s.create(p), s.vs, nil, nil)
|
||||
if s.NoError(err) {
|
||||
expected := s.create(exp)
|
||||
s.True(expected.Equals(types.Format_7_18, merged), "%s != %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, merged))
|
||||
s.True(expected.Equals(merged), "%s != %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, merged))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ func assertParseType(t *testing.T, code string, expected *types.Type) {
|
||||
t.Run(code, func(t *testing.T) {
|
||||
actual, err := ParseType(code)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, expected.Equals(types.Format_7_18, actual), "Expected: %s, Actual: %s", expected.Describe(context.Background(), types.Format_7_18), actual.Describe(context.Background(), types.Format_7_18))
|
||||
assert.True(t, expected.Equals(actual), "Expected: %s, Actual: %s", expected.Describe(context.Background(), types.Format_7_18), actual.Describe(context.Background(), types.Format_7_18))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func assertParse(t *testing.T, vrw types.ValueReadWriter, code string, expected
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
assert.True(t, expected.Equals(types.Format_7_18, actual), "Expected: %s, Actual: %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, actual))
|
||||
assert.True(t, expected.Equals(actual), "Expected: %s, Actual: %s", types.EncodedValue(context.Background(), types.Format_7_18, expected), types.EncodedValue(context.Background(), types.Format_7_18, actual))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ func (s *testSuite) TestDatabase() {
|
||||
assert := s.NewAssert()
|
||||
val := types.Bool(true)
|
||||
r := s.Database.WriteValue(context.Background(), val)
|
||||
assert.True(s.Database.ReadValue(context.Background(), r.TargetHash()).Equals(types.Format_7_18, val))
|
||||
assert.True(s.Database.ReadValue(context.Background(), r.TargetHash()).Equals(val))
|
||||
}
|
||||
|
||||
func (s *testSuite) TestTempFile() {
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestAbsolutePaths(t *testing.T) {
|
||||
if exp == nil {
|
||||
assert.Nil(act)
|
||||
} else {
|
||||
assert.True(exp.Equals(types.Format_7_18, act), "%s Expected %s Actual %s", str, types.EncodedValue(context.Background(), types.Format_7_18, exp), types.EncodedValue(context.Background(), types.Format_7_18, act))
|
||||
assert.True(exp.Equals(act), "%s Expected %s Actual %s", str, types.EncodedValue(context.Background(), types.Format_7_18, exp), types.EncodedValue(context.Background(), types.Format_7_18, act))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func isEmptyStruct(s types.Struct) bool {
|
||||
return s.Equals(types.Format_7_18, types.EmptyStruct(types.Format_7_18))
|
||||
return s.Equals(types.EmptyStruct(types.Format_7_18))
|
||||
}
|
||||
|
||||
func TestCreateCommitMetaStructBasic(t *testing.T) {
|
||||
|
||||
@@ -501,5 +501,5 @@ func TestExternalProtocol(t *testing.T) {
|
||||
ds, err = ds.Database().CommitValue(context.Background(), ds, types.String("hi!"))
|
||||
d.PanicIfError(err)
|
||||
|
||||
assert.True(types.String("hi!").Equals(types.Format_7_18, ds.HeadValue()))
|
||||
assert.True(types.String("hi!").Equals(ds.HeadValue()))
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func TestKVPCollItr(t *testing.T) {
|
||||
for _, expRes := range test.itrResults {
|
||||
kvp, buff, done := itr.nextForDestructiveMerge()
|
||||
|
||||
if !kvp.Key.Value(ctx).Equals(types.Format_7_18, types.Uint(expRes.keyVal)) {
|
||||
if !kvp.Key.Value(ctx).Equals(types.Uint(expRes.keyVal)) {
|
||||
t.Error("unexpected result")
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ func TestKVPSliceSort(t *testing.T) {
|
||||
}
|
||||
|
||||
for i := 0; i < len(test.kvps); i++ {
|
||||
if !test.kvps[i].Key.Value(ctx).Equals(types.Format_7_18, test.expSorted[i].Key.Value(ctx)) {
|
||||
if !test.kvps[i].Key.Value(ctx).Equals(test.expSorted[i].Key.Value(ctx)) {
|
||||
t.Error("value at", i, "does not match expected.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,10 +90,10 @@ func (s *perfSuite) Test05Concat10mValues2kTimes() {
|
||||
for i := uint64(0); i < 1e3; i++ { // 1k iterations * 2 concat ops = 2k times
|
||||
// Include some basic sanity checks.
|
||||
l3 = l3.Concat(context.Background(), l1)
|
||||
assert.True(l1Last.Equals(types.Format_7_18, last(l3)))
|
||||
assert.True(l1Last.Equals(last(l3)))
|
||||
assert.Equal(i*(l1Len+l2Len)+l1Len, l3.Len())
|
||||
l3 = l3.Concat(context.Background(), l2)
|
||||
assert.True(l2Last.Equals(types.Format_7_18, last(l3)))
|
||||
assert.True(l2Last.Equals(last(l3)))
|
||||
assert.Equal((i+1)*(l1Len+l2Len), l3.Len())
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ func TestMarshal(t *testing.T) {
|
||||
|
||||
assert.True(types.NewStruct(types.Format_7_18, "DateTime", types.StructData{
|
||||
"secSinceEpoch": types.Float(expected),
|
||||
}).Equals(types.Format_7_18, v))
|
||||
}).Equals(v))
|
||||
}
|
||||
|
||||
test(DateTime{time.Unix(0, 0)}, 0)
|
||||
|
||||
Reference in New Issue
Block a user