@@ -259,20 +259,76 @@ var _ = Describe("Types", func() {
259259 // }
260260 //
261261 // value := randSeq(20 * 1024)
262- // fmt.Println(value)
263- // fmt.Println()
264262 //
265263 // result, err = session.Run("CREATE (n {value: $value}) RETURN n.value", &map[string]interface{}{"value": value})
266264 // Expect(err).To(BeNil())
267265 //
268266 // if result.Next() {
269- // fmt.Println(result.Record().GetByIndex(0))
270- // fmt.Println()
271267 // Expect(result.Record().GetByIndex(0)).To(BeAssignableToTypeOf(""))
272268 // Expect(result.Record().GetByIndex(0)).To(Equal(value))
273269 // }
274270 // Expect(result.Next()).To(BeFalse())
275271 // Expect(result.Err()).To(BeNil())
276272 //})
277273
274+ It ("should be able to receive a node with properties" , func () {
275+ result , err = session .Run ("CREATE (n:Person:Manager {id: 1, name: 'a name'}) RETURN n" , nil )
276+ Expect (err ).To (BeNil ())
277+
278+ if result .Next () {
279+ node := result .Record ().GetByIndex (0 ).(Node )
280+
281+ Expect (node ).NotTo (BeNil ())
282+ Expect (node .Id ()).NotTo (BeNil ())
283+ Expect (node .Labels ()).To (HaveLen (2 ))
284+ Expect (node .Labels ()).To (ContainElement ("Person" ))
285+ Expect (node .Labels ()).To (ContainElement ("Manager" ))
286+ Expect (node .Props ()).To (HaveLen (2 ))
287+ Expect (node .Props ()).To (HaveKeyWithValue ("id" , int64 (1 )))
288+ Expect (node .Props ()).To (HaveKeyWithValue ("name" , "a name" ))
289+ }
290+ Expect (result .Next ()).To (BeFalse ())
291+ Expect (result .Err ()).To (BeNil ())
292+ })
293+
294+ It ("should be able to receive a relationship with properties" , func () {
295+ 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 )
296+ Expect (err ).To (BeNil ())
297+
298+ if result .Next () {
299+ employee := result .Record ().GetByIndex (0 ).(Node )
300+ worksFor := result .Record ().GetByIndex (1 ).(Relationship )
301+ manager := result .Record ().GetByIndex (2 ).(Node )
302+
303+ Expect (employee ).NotTo (BeNil ())
304+ Expect (employee .Id ()).NotTo (BeNil ())
305+ Expect (employee .Labels ()).To (HaveLen (2 ))
306+ Expect (employee .Labels ()).To (ContainElement ("Person" ))
307+ Expect (employee .Labels ()).To (ContainElement ("Employee" ))
308+ Expect (employee .Props ()).To (HaveLen (2 ))
309+ Expect (employee .Props ()).To (HaveKeyWithValue ("id" , int64 (1 )))
310+ Expect (employee .Props ()).To (HaveKeyWithValue ("name" , "employee 1" ))
311+
312+ Expect (worksFor ).NotTo (BeNil ())
313+ Expect (worksFor .Id ()).NotTo (BeNil ())
314+ Expect (worksFor .StartId ()).To (Equal (employee .Id ()))
315+ Expect (worksFor .EndId ()).To (Equal (manager .Id ()))
316+ Expect (worksFor .Type ()).To (Equal ("WORKS_FOR" ))
317+ Expect (worksFor .Props ()).To (HaveLen (1 ))
318+ Expect (worksFor .Props ()).To (HaveKeyWithValue ("from" , "2017-01-01" ))
319+
320+ Expect (manager ).NotTo (BeNil ())
321+ Expect (manager .Id ()).NotTo (BeNil ())
322+ Expect (manager .Labels ()).To (HaveLen (2 ))
323+ Expect (manager .Labels ()).To (ContainElement ("Person" ))
324+ Expect (manager .Labels ()).To (ContainElement ("Manager" ))
325+ Expect (manager .Props ()).To (HaveLen (2 ))
326+ Expect (manager .Props ()).To (HaveKeyWithValue ("id" , int64 (2 )))
327+ Expect (manager .Props ()).To (HaveKeyWithValue ("name" , "manager 1" ))
328+ }
329+ Expect (result .Next ()).To (BeFalse ())
330+ Expect (result .Err ()).To (BeNil ())
331+ })
332+
278333})
334+
0 commit comments