Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Add tests to check concern in #39
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolewhite committed Oct 5, 2015
1 parent 4d5ae3d commit 418708f
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/testthat/test-nodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ test_that("createNode works without any properties or labels", {
createNode(neo4j)
})

test_that("createNode works with properties set to NA", {
clear(neo4j, input=F)
n = createNode(neo4j, "Person", name="Nicole", age=NA)
expect_equal(n$name, "Nicole")
expect_null(n$age)
})

test_that("createNode works with properties set to NULL", {
clear(neo4j, input=F)
n = createNode(neo4j, "Person", name="Nicole", age=NULL)
expect_equal(n$name, "Nicole")
expect_null(n$age)
})

test_that("createNode doesn't round numeric parameters", {
clear(neo4j, input=F)
AGE = 123456789
Expand Down Expand Up @@ -77,6 +91,50 @@ test_that("getOrCreateNode works with last of parameters", {
expect_null(node$other)
})

test_that("getOrCreateNode works with NA properties when the node already exists", {
clear(neo4j, input=F)
addConstraint(neo4j, "Bar", "name")

mugshots = createNode(neo4j, "Bar", name="Mugshots", location="México")

n = getOrCreateNode(neo4j, "Bar", name="Mugshots", location=NA)

expect_equal(n$name, "Mugshots")
expect_equal(n$location, "México")
})

test_that("getOrCreateNode works with NULL properties when the node already exists", {
clear(neo4j, input=F)
addConstraint(neo4j, "Bar", "name")

mugshots = createNode(neo4j, "Bar", name="Mugshots", location="México")

n = getOrCreateNode(neo4j, "Bar", name="Mugshots", location=NULL)

expect_equal(n$name, "Mugshots")
expect_equal(n$location, "México")
})

test_that("getOrCreateNode works with NA properties when the node doesn't already exist", {
clear(neo4j, input=F)
addConstraint(neo4j, "User", "user_id_hash")

n = getOrCreateNode(neo4j, "User", user_id_hash="john", age=NA)

expect_equal(n$user_id_hash, "john")
expect_null(n$age)
})

test_that("getOrCreateNode works with NULL properties when the node doesn't already exist", {
clear(neo4j, input=F)
addConstraint(neo4j, "User", "user_id_hash")

n = getOrCreateNode(neo4j, "User", user_id_hash="john", age=NULL)

expect_equal(n$user_id_hash, "john")
expect_null(n$age)
})

test_that("getLabeledNodes works", {
clear(neo4j, input=F)

Expand Down

0 comments on commit 418708f

Please sign in to comment.