Files
dolt/nomdl/codegen/test/struct_test.go
Erik Arvidsson 72f4cd3a7a NomDL Codegen: Make the TypeRef return a package ref
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
2015-10-05 14:24:25 -07:00

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())
}