本文整理汇总了Golang中github.com/stretchr/testify/require.JSONEq函数的典型用法代码示例。如果您正苦于以下问题:Golang JSONEq函数的具体用法?Golang JSONEq怎么用?Golang JSONEq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JSONEq函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestIntersectsPolygon2
func TestIntersectsPolygon2(t *testing.T) {
dir, ps := createTestStore(t)
defer os.RemoveAll(dir)
defer ps.Close()
createTestData(t, ps)
gq := &gql.GraphQuery{
Alias: "me",
Func: &gql.Function{
Attr: "geometry",
Name: "intersects",
Args: []string{
`{"Type":"Polygon", "Coordinates":[[[-121.6, 37.1], [-122.4, 37.3],
[-122.6, 37.8], [-122.5, 38.3], [-121.9, 38], [-121.6, 37.1]]]}`,
},
},
Children: []*gql.GraphQuery{&gql.GraphQuery{Attr: "name"}},
}
mp := runQuery(t, gq)
expected := `{"me":[{"name":"Googleplex"},{"name":"Shoreline Amphitheater"},
{"name":"San Carlos Airport"},{"name":"SF Bay area"},
{"name":"Mountain View"},{"name":"San Carlos"}]}`
require.JSONEq(t, expected, mp)
}
示例2: requireTargetGroups
func requireTargetGroups(t *testing.T, expected, res []*config.TargetGroup) {
b1, err := json.Marshal(expected)
if err != nil {
panic(err)
}
b2, err := json.Marshal(res)
if err != nil {
panic(err)
}
require.JSONEq(t, string(b1), string(b2))
}
示例3: TestContainsGenerator
func TestContainsGenerator(t *testing.T) {
dir1, dir2, _ := populateGraph(t)
defer os.RemoveAll(dir1)
defer os.RemoveAll(dir2)
query := `{
me(contains("loc", "{'Type':'Point', 'Coordinates':[2.0, 0.0]}")) {
name
}
}`
js := processToJSON(t, query)
require.JSONEq(t, `{"me":[{"name":"Rick Grimes"}]}`, string(js))
}
示例4: TestIntersectsGenerator
func TestIntersectsGenerator(t *testing.T) {
dir1, dir2, _ := populateGraph(t)
defer os.RemoveAll(dir1)
defer os.RemoveAll(dir2)
query := `{
me(intersects("loc", "{'Type':'Polygon', 'Coordinates':[[[0.0,0.0], [2.0,0.0], [1.5, 3.0], [0.0, 2.0]]]}")) {
name
}
}`
js := processToJSON(t, query)
require.JSONEq(t, `{"me":[{"name":"Michonne"}, {"name":"Rick Grimes"}]}`, string(js))
}
示例5: TestGeneratorMultiRoot
func TestGeneratorMultiRoot(t *testing.T) {
dir1, dir2, _ := populateGraph(t)
defer os.RemoveAll(dir1)
defer os.RemoveAll(dir2)
query := `
{
me(anyof("name", "Michonne Rick Glenn")) {
name
}
}
`
js := processToJSON(t, query)
require.JSONEq(t, `{"me":[{"name":"Michonne"},{"name":"Rick Grimes"},{"name":"Glenn Rhee"}]}`, js)
}
示例6: TestNearGenerator
func TestNearGenerator(t *testing.T) {
dir1, dir2, _ := populateGraph(t)
defer os.RemoveAll(dir1)
defer os.RemoveAll(dir2)
query := `{
me(near("loc", "{'Type':'Point', 'Coordinates':[1.1,2.0]}", "5")) {
name
gender
}
}`
js := processToJSON(t, query)
require.JSONEq(t, `{"me":[{"gender":"female","name":"Michonne"}]}`, string(js))
}
示例7: TestGenerator
func TestGenerator(t *testing.T) {
dir1, dir2, _ := populateGraph(t)
defer os.RemoveAll(dir1)
defer os.RemoveAll(dir2)
query := `
{
me(anyof("name", "Michonne")) {
name
gender
}
}
`
js := processToJSON(t, query)
require.JSONEq(t, `{"me":[{"gender":"female","name":"Michonne"}]}`, js)
}
示例8: TestContainsPoint
func TestContainsPoint(t *testing.T) {
dir, ps := createTestStore(t)
defer os.RemoveAll(dir)
defer ps.Close()
createTestData(t, ps)
gq := &gql.GraphQuery{
Alias: "me",
Func: &gql.Function{Attr: "geometry", Name: "contains", Args: []string{
`{"Type":"Point", "Coordinates":[-122.082506, 37.4249518]}`},
},
Children: []*gql.GraphQuery{&gql.GraphQuery{Attr: "name"}},
}
mp := runQuery(t, gq)
expected := `{"me":[{"name":"SF Bay area"},{"name":"Mountain View"}]}`
require.JSONEq(t, expected, mp)
}
示例9: TestNearPoint
func TestNearPoint(t *testing.T) {
dir, ps := createTestStore(t)
defer os.RemoveAll(dir)
defer ps.Close()
createTestData(t, ps)
gq := &gql.GraphQuery{
Alias: "me",
Func: &gql.Function{
Attr: "geometry",
Name: "near",
Args: []string{`{"Type":"Point", "Coordinates":[-122.082506, 37.4249518]}`, "1000"},
},
Children: []*gql.GraphQuery{&gql.GraphQuery{Attr: "name"}},
}
mp := runQuery(t, gq)
expected := `{"me":[{"name":"Googleplex"},{"name":"Shoreline Amphitheater"}]}`
require.JSONEq(t, expected, mp)
}
示例10: TestWithinPolygon
func TestWithinPolygon(t *testing.T) {
dir, ps := createTestStore(t)
defer os.RemoveAll(dir)
defer ps.Close()
createTestData(t, ps)
gq := &gql.GraphQuery{
Alias: "me",
Func: &gql.Function{Attr: "geometry", Name: "within", Args: []string{
`{"Type":"Polygon", "Coordinates":[[[-122.06, 37.37], [-122.1, 37.36],
[-122.12, 37.4], [-122.11, 37.43], [-122.04, 37.43], [-122.06, 37.37]]]}`},
},
Children: []*gql.GraphQuery{&gql.GraphQuery{Attr: "name"}},
}
mp := runQuery(t, gq)
expected := `{"me":[{"name":"Googleplex"},{"name":"Shoreline Amphitheater"}]}`
require.JSONEq(t, expected, mp)
}
示例11: TestToJSONFilterGeqNoResult
func TestToJSONFilterGeqNoResult(t *testing.T) {
dir, dir2, _ := populateGraph(t)
defer os.RemoveAll(dir)
defer os.RemoveAll(dir2)
query := `
{
me(_uid_:0x01) {
name
gender
friend @filter(geq("dob", "1999-03-20")) {
name
}
}
}
`
js := processToJSON(t, query)
require.JSONEq(t,
`{"me":[{"gender":"female","name":"Michonne"}]}`, js)
}
示例12: TestToJSONFilterOrFirstOffsetCount
func TestToJSONFilterOrFirstOffsetCount(t *testing.T) {
dir, dir2, _ := populateGraph(t)
defer os.RemoveAll(dir)
defer os.RemoveAll(dir2)
query := `
{
me(_uid_:0x01) {
name
gender
friend(offset:1, first:1) @filter(anyof("name", "Andrea") || anyof("name", "SomethingElse Rhee") || anyof("name", "Daryl Dixon")) {
_count_
}
}
}
`
js := processToJSON(t, query)
require.JSONEq(t,
`{"me":[{"friend":[{"_count_":1}],"gender":"female","name":"Michonne"}]}`,
js)
}
示例13: TestToJSONFilterLeqFirstOffset
func TestToJSONFilterLeqFirstOffset(t *testing.T) {
dir, dir2, _ := populateGraph(t)
defer os.RemoveAll(dir)
defer os.RemoveAll(dir2)
query := `
{
me(_uid_:0x01) {
name
gender
friend(offset:1, first:1) @filter(leq("dob", "1909-03-20")) {
name
}
}
}
`
js := processToJSON(t, query)
require.JSONEq(t,
`{"me":[{"friend":[{"name":"Andrea"}],"gender":"female","name":"Michonne"}]}`,
js)
}
示例14: TestToJSONFilterOrCount
func TestToJSONFilterOrCount(t *testing.T) {
dir, dir2, _ := populateGraph(t)
defer os.RemoveAll(dir)
defer os.RemoveAll(dir2)
query := `
{
me(_uid_:0x01) {
name
gender
friend @filter(anyof("name", "Andrea") || anyof("name", "Andrea Rhee")) {
_count_
}
}
}
`
js := processToJSON(t, query)
require.JSONEq(t,
`{"me":[{"friend":[{"_count_":2}],"gender":"female","name":"Michonne"}]}`,
js)
}
示例15: TestGetUIDCount
func TestGetUIDCount(t *testing.T) {
dir, dir2, _ := populateGraph(t)
defer os.RemoveAll(dir)
defer os.RemoveAll(dir2)
query := `
{
me(_uid_:0x01) {
name
_uid_
gender
alive
friend {
_count_
}
}
}
`
js := processToJSON(t, query)
require.JSONEq(t,
`{"me":[{"_uid_":"0x1","alive":true,"friend":[{"_count_":5}],"gender":"female","name":"Michonne"}]}`,
js)
}