Skip to content

Commit 8c44e44

Browse files
committed
[add] Included test case of issue #30
1 parent 0d2ae96 commit 8c44e44

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

client_test.go

+44
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,47 @@ func TestUtils(t *testing.T) {
429429
res = ToString(jsonMap)
430430
assert.Equal(t, res, "{object: {foo: 1}}")
431431
}
432+
433+
func TestNodeMapDatatype(t *testing.T) {
434+
graph.Flush()
435+
err := graph.Delete()
436+
assert.Nil(t, err)
437+
438+
// Create 2 nodes connect via a single edge.
439+
japan := NodeNew("Country", "j",
440+
map[string]interface{}{
441+
"name": "Japan",
442+
"population": 126800000,
443+
"states": []string{"Kanto", "Chugoku"},
444+
})
445+
john := NodeNew("Person", "p",
446+
map[string]interface{}{
447+
"name": "John Doe",
448+
"age": 33,
449+
"gender": "male",
450+
"status": "single",
451+
})
452+
edge := EdgeNew("Visited", john, japan, map[string]interface{}{"year": 2017})
453+
// Introduce entities to graph.
454+
graph.AddNode(john)
455+
graph.AddNode(japan)
456+
graph.AddEdge(edge)
457+
458+
// Flush graph to DB.
459+
res, err := graph.Commit()
460+
assert.Nil(t, err)
461+
assert.Equal(t, 2, res.NodesCreated(), "Expecting 2 node created")
462+
assert.Equal(t, 0, res.NodesDeleted(), "Expecting 0 nodes deleted")
463+
assert.Equal(t, 8, res.PropertiesSet(), "Expecting 8 properties set")
464+
assert.Equal(t, 1, res.RelationshipsCreated(), "Expecting 1 relationships created")
465+
assert.Equal(t, 0, res.RelationshipsDeleted(), "Expecting 0 relationships deleted")
466+
assert.Greater(t, res.InternalExecutionTime(), 0.0, "Expecting internal execution time not to be 0.0")
467+
assert.Equal(t, true, res.Empty(), "Expecting empty resultset")
468+
res, err = graph.Query("MATCH p = (:Person)-[:Visited]->(:Country) RETURN p")
469+
assert.Nil(t, err)
470+
assert.Equal(t, len(res.results), 1, "expecting 1 result record")
471+
assert.Equal(t, false, res.Empty(), "Expecting resultset to have records")
472+
res, err = graph.Query("MATCH ()-[r]-() DELETE r")
473+
assert.Nil(t, err)
474+
assert.Equal(t, 1, res.RelationshipsDeleted(), "Expecting 1 relationships deleted")
475+
}

0 commit comments

Comments
 (0)