Skip to content

Commit

Permalink
Merge pull request #6 from ali-ince/fix-graph-types
Browse files Browse the repository at this point in the history
Add tests for graph types
  • Loading branch information
ali-ince authored Jul 20, 2018
2 parents 75110ea + 2e0dfee commit f2d36e6
Showing 1 changed file with 60 additions and 4 deletions.
64 changes: 60 additions & 4 deletions integration-tests/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,20 +259,76 @@ var _ = Describe("Types", func() {
// }
//
// value := randSeq(20 * 1024)
// fmt.Println(value)
// fmt.Println()
//
// result, err = session.Run("CREATE (n {value: $value}) RETURN n.value", &map[string]interface{}{"value": value})
// Expect(err).To(BeNil())
//
// if result.Next() {
// fmt.Println(result.Record().GetByIndex(0))
// fmt.Println()
// Expect(result.Record().GetByIndex(0)).To(BeAssignableToTypeOf(""))
// Expect(result.Record().GetByIndex(0)).To(Equal(value))
// }
// Expect(result.Next()).To(BeFalse())
// Expect(result.Err()).To(BeNil())
//})

It("should be able to receive a node with properties", func() {
result, err = session.Run("CREATE (n:Person:Manager {id: 1, name: 'a name'}) RETURN n", nil)
Expect(err).To(BeNil())

if result.Next() {
node := result.Record().GetByIndex(0).(Node)

Expect(node).NotTo(BeNil())
Expect(node.Id()).NotTo(BeNil())
Expect(node.Labels()).To(HaveLen(2))
Expect(node.Labels()).To(ContainElement("Person"))
Expect(node.Labels()).To(ContainElement("Manager"))
Expect(node.Props()).To(HaveLen(2))
Expect(node.Props()).To(HaveKeyWithValue("id", int64(1)))
Expect(node.Props()).To(HaveKeyWithValue("name", "a name"))
}
Expect(result.Next()).To(BeFalse())
Expect(result.Err()).To(BeNil())
})

It("should be able to receive a relationship with properties", func() {
result, err = session.Run("CREATE (e:Person:Employee {id: 1, name: 'employee 1'})-[w:WORKS_FOR { from: '2017-01-01' }]->(m:Person:Manager {id: 2, name: 'manager 1'}) RETURN e, w, m", nil)
Expect(err).To(BeNil())

if result.Next() {
employee := result.Record().GetByIndex(0).(Node)
worksFor := result.Record().GetByIndex(1).(Relationship)
manager := result.Record().GetByIndex(2).(Node)

Expect(employee).NotTo(BeNil())
Expect(employee.Id()).NotTo(BeNil())
Expect(employee.Labels()).To(HaveLen(2))
Expect(employee.Labels()).To(ContainElement("Person"))
Expect(employee.Labels()).To(ContainElement("Employee"))
Expect(employee.Props()).To(HaveLen(2))
Expect(employee.Props()).To(HaveKeyWithValue("id", int64(1)))
Expect(employee.Props()).To(HaveKeyWithValue("name", "employee 1"))

Expect(worksFor).NotTo(BeNil())
Expect(worksFor.Id()).NotTo(BeNil())
Expect(worksFor.StartId()).To(Equal(employee.Id()))
Expect(worksFor.EndId()).To(Equal(manager.Id()))
Expect(worksFor.Type()).To(Equal("WORKS_FOR"))
Expect(worksFor.Props()).To(HaveLen(1))
Expect(worksFor.Props()).To(HaveKeyWithValue("from", "2017-01-01"))

Expect(manager).NotTo(BeNil())
Expect(manager.Id()).NotTo(BeNil())
Expect(manager.Labels()).To(HaveLen(2))
Expect(manager.Labels()).To(ContainElement("Person"))
Expect(manager.Labels()).To(ContainElement("Manager"))
Expect(manager.Props()).To(HaveLen(2))
Expect(manager.Props()).To(HaveKeyWithValue("id", int64(2)))
Expect(manager.Props()).To(HaveKeyWithValue("name", "manager 1"))
}
Expect(result.Next()).To(BeFalse())
Expect(result.Err()).To(BeNil())
})

})

0 comments on commit f2d36e6

Please sign in to comment.