当前位置: 首页>>代码示例>>Golang>>正文


Golang require.JSONEq函数代码示例

本文整理汇总了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)
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:25,代码来源:geo_test.go

示例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))
}
开发者ID:prometheus,项目名称:prometheus,代码行数:12,代码来源:node_test.go

示例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))
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:13,代码来源:query_test.go

示例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))
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:13,代码来源:query_test.go

示例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)
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:14,代码来源:query_test.go

示例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))
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:14,代码来源:query_test.go

示例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)
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:15,代码来源:query_test.go

示例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)
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:18,代码来源:geo_test.go

示例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)
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:20,代码来源:geo_test.go

示例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)
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:20,代码来源:geo_test.go

示例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)
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:20,代码来源:query_test.go

示例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)
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:21,代码来源:query_test.go

示例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)
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:21,代码来源:query_test.go

示例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)
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:21,代码来源:query_test.go

示例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)
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:22,代码来源:query_test.go


注:本文中的github.com/stretchr/testify/require.JSONEq函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。