github.com/holochain/holochain-proto@v0.1.0-alpha-26.0.20200915073418-5c83169c9b5b/zome_test.go (about) 1 package holochain 2 3 import ( 4 // "fmt" 5 . "github.com/smartystreets/goconvey/convey" 6 "testing" 7 ) 8 9 func TestZomeGetEntryDef(t *testing.T) { 10 d, _, h := SetupTestChain("test") 11 defer CleanupTestChain(h, d) 12 13 z, _ := h.GetZome("zySampleZome") 14 15 Convey("it should fail on an undefined entry type", t, func() { 16 _, err := z.GetEntryDef("bar") 17 So(err.Error(), ShouldEqual, "no definition for entry type: bar") 18 }) 19 Convey("it should get a defined entry type", t, func() { 20 z := h.nucleus.dna.Zomes[0] 21 d, err := z.GetEntryDef("primes") 22 So(err, ShouldBeNil) 23 So(d.Name, ShouldEqual, "primes") 24 }) 25 } 26 27 func TestGetFunctionDef(t *testing.T) { 28 d, _, h := SetupTestChain("test") 29 defer CleanupTestChain(h, d) 30 31 z, _ := h.GetZome("zySampleZome") 32 33 Convey("it should fail if the fn isn't defined in the DNA", t, func() { 34 _, err := z.GetFunctionDef("foo") 35 So(err.Error(), ShouldEqual, "unknown exposed function: foo") 36 }) 37 Convey("it should return the Fn structure of a defined fn", t, func() { 38 fn, err := z.GetFunctionDef("getDNA") 39 So(err, ShouldBeNil) 40 So(fn.Name, ShouldEqual, "getDNA") 41 }) 42 }