mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-22 00:49:29 -06:00
The TypeRef function for a Noms Struct should be the (Name, PkgRef) and not the description of the struct fields. This is important because when serializing we need to write the package ref. Towards #281 #304
46 lines
857 B
Go
46 lines
857 B
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/attic-labs/noms/Godeps/_workspace/src/github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDef(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
def := StructDef{"hi", true}
|
|
st := def.New()
|
|
|
|
def2 := st.Def()
|
|
st2 := def.New()
|
|
|
|
assert.Equal(def, def2)
|
|
assert.True(st.Equals(st2))
|
|
|
|
st3 := NewStruct()
|
|
st3 = st3.SetS("hi").SetB(true)
|
|
assert.Equal("hi", st3.S())
|
|
assert.Equal(true, st3.B())
|
|
}
|
|
|
|
func TestValue(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
def := StructDef{"hi", true}
|
|
st := def.New()
|
|
val := st.NomsValue()
|
|
st2 := StructFromVal(val)
|
|
assert.True(st.Equals(st2))
|
|
}
|
|
|
|
func TestTypeRef(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
def := StructDef{"hi", true}
|
|
st := def.New()
|
|
typ := st.TypeRef()
|
|
assert.Equal("Struct", typ.Name())
|
|
assert.EqualValues(__testPackageInFile_struct_Ref(), typ.PackageRef())
|
|
}
|