本文整理匯總了Golang中kego/io/tests/data.Setup函數的典型用法代碼示例。如果您正苦於以下問題:Golang Setup函數的具體用法?Golang Setup怎麽用?Golang Setup使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Setup函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestNode_DeleteArrayChild
func TestNode_DeleteArrayChild(t *testing.T) {
_, n := data.Setup(t)
test := func(t *testing.T, n *node.Node, m *data.Multi) {
require.NoError(t, n.Map["ajs"].DeleteArrayChild(1))
assert.Equal(t, 3, len(n.Map["ajs"].Array))
assert.Equal(t, 0, n.Map["ajs"].Array[0].Index)
assert.Equal(t, 1, n.Map["ajs"].Array[1].Index)
assert.Equal(t, 2, n.Map["ajs"].Array[2].Index)
assert.Equal(t, []string{"ajs0", "ajs2", "ajs3"}, m.Ajs)
require.NoError(t, n.Map["ajs"].DeleteArrayChild(2))
assert.Equal(t, 2, len(n.Map["ajs"].Array))
assert.Equal(t, 0, n.Map["ajs"].Array[0].Index)
assert.Equal(t, 1, n.Map["ajs"].Array[1].Index)
assert.Equal(t, []string{"ajs0", "ajs2"}, m.Ajs)
require.NoError(t, n.Map["ajs"].DeleteArrayChild(0))
assert.Equal(t, 1, len(n.Map["ajs"].Array))
assert.Equal(t, 0, n.Map["ajs"].Array[0].Index)
assert.Equal(t, []string{"ajs2"}, m.Ajs)
require.NoError(t, n.Map["ajs"].DeleteArrayChild(0))
assert.Equal(t, 0, len(n.Map["ajs"].Array))
assert.Equal(t, []string{}, m.Ajs)
}
data.Run(t, n, n.Value.(*data.Multi), test)
}
示例2: TestNode_DeleteArrayChild2
func TestNode_DeleteArrayChild2(t *testing.T) {
_, n := data.Setup(t)
err := n.DeleteArrayChild(0)
assert.IsError(t, err, "NFVEWWCSMV")
err = n.Map["mjs"].DeleteArrayChild(0)
assert.IsError(t, err, "NFVEWWCSMV")
}
示例3: TestNode_InitialiseMapChild
func TestNode_InitialiseMapChild(t *testing.T) {
cb, n := data.Setup(t)
test := func(t *testing.T, n *node.Node, m *data.Multi) {
c := node.NewNode()
require.NoError(t, c.InitialiseMapItem(cb.Ctx(), n.Map["mjs"], "c"))
require.NoError(t, c.AddToMap(cb.Ctx(), n.Map["mjs"], "c", true))
assert.Equal(t, 3, len(n.Map["mjs"].Map))
assert.True(t, n.Map["mjs"].Map["c"].Null)
assert.False(t, n.Map["mjs"].Map["c"].Missing)
assert.Equal(t, c, n.Map["mjs"].Map["c"])
assert.Equal(t, "", m.Mjs["c"])
c1 := node.NewNode()
require.NoError(t, c1.InitialiseMapItem(cb.Ctx(), n.Map["mss"], "c"))
require.NoError(t, c1.AddToMap(cb.Ctx(), n.Map["mss"], "c", true))
assert.Equal(t, 3, len(n.Map["mss"].Map))
assert.Nil(t, m.Mss["c"])
c2 := node.NewNode()
require.NoError(t, c2.InitialiseMapItem(cb.Ctx(), n.Map["mm"], "c"))
require.NoError(t, c2.AddToMap(cb.Ctx(), n.Map["mm"], "c", true))
assert.Equal(t, 3, len(m.Mm))
assert.Nil(t, m.Mm["c"])
}
data.Run(t, n, n.Value.(*data.Multi), test)
}
示例4: TestNode_DeleteMapChild2
func TestNode_DeleteMapChild2(t *testing.T) {
_, n := data.Setup(t)
err := n.DeleteMapChild("js")
assert.IsError(t, err, "ACRGPCPPFK")
err = n.Map["ajs"].DeleteMapChild("a")
assert.IsError(t, err, "ACRGPCPPFK")
}
示例5: TestNode_DeleteObjectChild
func TestNode_DeleteObjectChild(t *testing.T) {
cb, n := data.Setup(t)
test := func(t *testing.T, n *node.Node, m *data.Multi) {
require.NoError(t, n.DeleteObjectChild(cb.Ctx(), "js"))
assert.True(t, n.Map["js"].Missing)
assert.Equal(t, "", m.Js)
require.NoError(t, n.DeleteObjectChild(cb.Ctx(), "ss"))
assert.Nil(t, m.Ss)
require.NoError(t, n.DeleteObjectChild(cb.Ctx(), "sr"))
assert.Nil(t, m.Sr)
require.NoError(t, n.DeleteObjectChild(cb.Ctx(), "jn"))
assert.Equal(t, 0.0, m.Jn)
require.NoError(t, n.DeleteObjectChild(cb.Ctx(), "sn"))
assert.Nil(t, m.Sn)
require.NoError(t, n.DeleteObjectChild(cb.Ctx(), "jb"))
assert.Equal(t, false, m.Jb)
require.NoError(t, n.DeleteObjectChild(cb.Ctx(), "sb"))
assert.Nil(t, m.Sb)
require.NoError(t, n.DeleteObjectChild(cb.Ctx(), "i"))
assert.Nil(t, m.I)
require.NoError(t, n.DeleteObjectChild(cb.Ctx(), "ajs"))
assert.Nil(t, m.Ajs)
require.NoError(t, n.DeleteObjectChild(cb.Ctx(), "mjs"))
assert.Nil(t, m.Mjs)
}
data.Run(t, n, n.Value.(*data.Multi), test)
}
示例6: TestNode_DeleteObjectChild2
func TestNode_DeleteObjectChild2(t *testing.T) {
cb, n := data.Setup(t)
err := n.Map["mjs"].DeleteObjectChild(cb.Ctx(), "a")
assert.IsError(t, err, "BMUSITINTC")
err = n.Map["ajs"].DeleteObjectChild(cb.Ctx(), "a")
assert.IsError(t, err, "BMUSITINTC")
}
示例7: TestNode_SetValueNumber
func TestNode_SetValueNumber(t *testing.T) {
cb, n := data.Setup(t)
test := func(t *testing.T, n *node.Node, m *data.Multi) {
n.Map["jn"].SetValueNumber(cb.Ctx(), 11.0)
assert.Equal(t, 11.0, m.Jn)
n.Map["sn"].SetValueNumber(cb.Ctx(), 12.0)
assert.Equal(t, 12.0, m.Sn.Value())
n.Map["ajn"].Array[0].SetValueNumber(cb.Ctx(), 13.0)
assert.Equal(t, 13.0, m.Ajn[0])
n.Map["ajn"].Array[1].SetValueNumber(cb.Ctx(), 14.0)
assert.Equal(t, 14.0, m.Ajn[1])
n.Map["mjn"].Map["a"].SetValueNumber(cb.Ctx(), 15.0)
assert.Equal(t, 15.0, m.Mjn["a"])
n.Map["mjn"].Map["b"].SetValueNumber(cb.Ctx(), 16.0)
assert.Equal(t, 16.0, m.Mjn["b"])
}
data.Run(t, n, n.Value.(*data.Multi), test)
}
示例8: TestNode_SetValueBool
func TestNode_SetValueBool(t *testing.T) {
cb, n := data.Setup(t)
test := func(t *testing.T, n *node.Node, m *data.Multi) {
n.Map["jb"].SetValueBool(cb.Ctx(), true)
assert.Equal(t, true, m.Jb)
n.Map["sb"].SetValueBool(cb.Ctx(), true)
assert.Equal(t, true, m.Sb.Value())
n.Map["ajb"].Array[0].SetValueBool(cb.Ctx(), true)
assert.Equal(t, true, m.Ajb[0])
n.Map["ajb"].Array[1].SetValueBool(cb.Ctx(), true)
assert.Equal(t, true, m.Ajb[1])
n.Map["mjb"].Map["a"].SetValueBool(cb.Ctx(), true)
assert.Equal(t, true, m.Mjb["a"])
n.Map["mjb"].Map["b"].SetValueBool(cb.Ctx(), true)
assert.Equal(t, true, m.Mjb["b"])
}
data.Run(t, n, n.Value.(*data.Multi), test)
}
示例9: TestNode_NativeValue
func TestNode_NativeValue(t *testing.T) {
_, n := data.Setup(t)
test := func(t *testing.T, n *node.Node, m *data.Multi) {
require.Equal(t, "js1", n.Map["js"].NativeValue())
require.Equal(t, "ss1", n.Map["ss"].NativeValue())
require.Equal(t, true, n.Map["jb"].NativeValue())
require.Equal(t, false, n.Map["sb"].NativeValue())
require.Equal(t, 1.1, n.Map["jn"].NativeValue())
require.Equal(t, 1.2, n.Map["sn"].NativeValue())
require.Equal(t, nil, n.Map["ajs"].NativeValue())
require.Equal(t, nil, n.Map["mjs"].NativeValue())
require.Equal(t, true, n.Map["aljb"].NativeValue())
require.Equal(t, 2.0, n.Map["aljn"].NativeValue())
require.Equal(t, "aljs", n.Map["aljs"].NativeValue())
}
data.Run(t, n, n.Value.(*data.Multi), test)
}
示例10: TestNode_SetValueString
func TestNode_SetValueString(t *testing.T) {
cb, n := data.Setup(t)
test := func(t *testing.T, n *node.Node, m *data.Multi) {
n.Map["js"].SetValueString(cb.Ctx(), "aa")
assert.Equal(t, "aa", m.Js)
n.Map["ss"].SetValueString(cb.Ctx(), "bb")
assert.Equal(t, "bb", m.Ss.Value())
n.Map["sr"].SetValueString(cb.Ctx(), "cc")
assert.Equal(t, "cc", m.Sr.Name)
n.Map["i"].Map["a"].SetValueString(cb.Ctx(), "dd")
assert.Equal(t, "dd", m.I.Face())
n.Map["ajs"].Array[0].SetValueString(cb.Ctx(), "ee")
assert.Equal(t, "ee", m.Ajs[0])
n.Map["ajs"].Array[1].SetValueString(cb.Ctx(), "ff")
assert.Equal(t, "ff", m.Ajs[1])
n.Map["mjs"].Map["a"].SetValueString(cb.Ctx(), "gg")
assert.Equal(t, "gg", m.Mjs["a"])
n.Map["mjs"].Map["b"].SetValueString(cb.Ctx(), "hh")
assert.Equal(t, "hh", m.Mjs["b"])
}
data.Run(t, n, n.Value.(*data.Multi), test)
}
示例11: TestDeleteMutation1
func TestDeleteMutation1(t *testing.T) {
cb, n := data.Setup(t)
test := func(t *testing.T, n *node.Node, m *data.Multi) {
var b, d, p *node.Node
b = node.NewNode()
d = n.Map["am"].Array[0]
p = n.Map["am"]
assert.Equal(t, "amjs0", n.Map["am"].Array[0].Map["js"].ValueString)
assert.Equal(t, "amjs1", n.Map["am"].Array[1].Map["js"].ValueString)
assert.Equal(t, "amjs0", m.Am[0].Js)
assert.Equal(t, "amjs1", m.Am[1].Js)
require.NoError(t, mutateDeleteNode(cb.Ctx(), d, p, b))
assert.Equal(t, 1, len(n.Map["am"].Array))
assert.Equal(t, 1, len(m.Am))
assert.Equal(t, "amjs1", n.Map["am"].Array[0].Map["js"].ValueString)
assert.Equal(t, "amjs1", m.Am[0].Js)
require.NoError(t, mutateRestoreNode(cb.Ctx(), d, p, b))
assert.Equal(t, 2, len(n.Map["am"].Array))
assert.Equal(t, 2, len(m.Am))
assert.Equal(t, "amjs0", n.Map["am"].Array[0].Map["js"].ValueString)
assert.Equal(t, "amjs1", n.Map["am"].Array[1].Map["js"].ValueString)
assert.Equal(t, "amjs0", m.Am[0].Js)
assert.Equal(t, "amjs1", m.Am[1].Js)
}
test(t, n.Map["m"], n.Value.(*data.Multi).M)
}
示例12: TestNode_Backup
func TestNode_Backup(t *testing.T) {
cb, n := data.Setup(t)
test := func(t *testing.T, n *node.Node, m *data.Multi) {
var err error
b := n.Backup()
err = n.RecomputeHash(cb.Ctx(), true)
require.NoError(t, err)
err = b.RecomputeHash(cb.Ctx(), true)
require.NoError(t, err)
require.Equal(t, b.Hash(), n.Hash())
require.Equal(t, b.Value, n.Value)
r := &node.Node{}
r.Restore(cb.Ctx(), b)
err = r.RecomputeHash(cb.Ctx(), true)
require.NoError(t, err)
require.Equal(t, r.Hash(), n.Hash())
require.Equal(t, r.Value, n.Value)
}
data.Run(t, n, n.Value.(*data.Multi), test)
}
示例13: TestNode_ReorderArrayChild2
func TestNode_ReorderArrayChild2(t *testing.T) {
_, n := data.Setup(t)
err := n.ReorderArrayChild(0, 1)
assert.IsError(t, err, "MHEXGBUQOL")
err = n.Map["mjs"].ReorderArrayChild(0, 1)
assert.IsError(t, err, "MHEXGBUQOL")
}
示例14: TestData
func TestData(t *testing.T) {
_, n := data.Setup(t)
test := func(t *testing.T, n *node.Node, m *data.Multi) {
require.Equal(t, "almsa", m.Alms["a"].Js)
}
data.Run(t, n, n.Value.(*data.Multi), test)
}
示例15: TestAddMutationRoot
func TestAddMutationRoot(t *testing.T) {
cb, _ := data.Setup(t)
a := node.NewNode()
ty, ok := system.GetTypeFromCache(cb.Ctx(), "kego.io/tests/data", "multi")
require.True(t, ok)
require.NoError(t, mutateAddNode(cb.Ctx(), a, nil, "", 2, ty, "z"))
require.NotNil(t, a.Value.(*data.Multi).Id)
require.Equal(t, "z", a.Value.(*data.Multi).Id.Name)
}