Skip to content

Commit

Permalink
Update tests from character to logical
Browse files Browse the repository at this point in the history
The parser for type_convert() has gotten smarter so that it picks up "true" and "false" and converts them into actual logicals so our tests need to change to reflect that
  • Loading branch information
StevenMMortimer committed Dec 17, 2018
1 parent 77cc561 commit 104080a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
24 changes: 11 additions & 13 deletions tests/testthat/test-bulk.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_that("testing Bulk 1.0 Functionality", {
expect_is(created_records, "tbl_df")
expect_named(created_records, c("Id", "Success", "Created", "Error"))
expect_equal(nrow(created_records), nrow(new_contacts))
expect_true(all(created_records$Success == "true"))
expect_true(all(created_records$Success))

# sf_retrieve ----------------------------------------------------------------
expect_error(
Expand Down Expand Up @@ -66,8 +66,8 @@ test_that("testing Bulk 1.0 Functionality", {
expect_is(updated_records, "tbl_df")
expect_named(updated_records, c("Id", "Success", "Created", "Error"))
expect_equal(nrow(updated_records), nrow(queried_records))
expect_true(all(updated_records$Success == "true"))
expect_true(all(updated_records$Created == "false"))
expect_true(all(updated_records$Success))
expect_true(all(!updated_records$Created))

new_record <- tibble(FirstName = "Test",
LastName = paste0("Contact-Upsert-", n+1),
Expand All @@ -83,19 +83,17 @@ test_that("testing Bulk 1.0 Functionality", {
expect_is(upserted_records, "tbl_df")
expect_named(upserted_records, c("Id", "Success", "Created", "Error"))
expect_equal(nrow(upserted_records), nrow(upserted_contacts))
expect_true(all(upserted_records$Success == "true"))
expect_equal(upserted_records$Created, c("false", "false", "true"))
expect_true(all(upserted_records$Success))
expect_equal(upserted_records$Created, c(FALSE, FALSE, TRUE))

# sf_delete ------------------------------------------------------------------
ids_to_delete <- unique(c(upserted_records$Id, queried_records$Id))
deleted_records <- sf_delete(ids_to_delete, object_name="Contact", api_type = "Bulk 1.0")
expect_is(deleted_records, "tbl_df")
expect_named(deleted_records, c("Id", "Success", "Created", "Error"))
expect_equal(nrow(deleted_records), length(ids_to_delete))
print(deleted_records$Success)
expect_true(all(deleted_records$Success == "true"))
print(deleted_records$Created)
expect_true(all(deleted_records$Created == "false"))
expect_true(all(deleted_records$Success))
expect_true(all(!deleted_records$Created))
})

context("Bulk 2.0")
Expand All @@ -115,7 +113,7 @@ test_that("testing Bulk 2.0 Functionality", {
"My_External_Id__c", "test_number__c", "sf__Error"))
expect_equal(nrow(created_records), n)
expect_true(all(is.na(created_records$sf__Error)))
expect_true(all(created_records$sf__Created == "true"))
expect_true(all(created_records$sf__Created))

# sf_retrieve ----------------------------------------------------------------
expect_error(
Expand Down Expand Up @@ -158,7 +156,7 @@ test_that("testing Bulk 2.0 Functionality", {
"My_External_Id__c", "test_number__c", "sf__Error"))
expect_equal(nrow(updated_records), nrow(queried_records))
expect_true(all(is.na(updated_records$sf__Error)))
expect_true(all(updated_records$sf__Created == "false"))
expect_true(all(updated_records$sf__Created))

new_record <- tibble(FirstName = "Test",
LastName = paste0("Contact-Upsert-", n+1),
Expand All @@ -176,7 +174,7 @@ test_that("testing Bulk 2.0 Functionality", {
"My_External_Id__c", "test_number__c", "sf__Error"))
expect_equal(nrow(upserted_records), nrow(upserted_contacts))
expect_true(all(is.na(upserted_records$sf__Error)))
expect_equal(upserted_records$sf__Created, c("false", "false", "true"))
expect_equal(upserted_records$sf__Created, c(FALSE, FALSE, TRUE))

# sf_delete ------------------------------------------------------------------
ids_to_delete <- unique(c(upserted_records$sf__Id, queried_records$Id))
Expand All @@ -185,5 +183,5 @@ test_that("testing Bulk 2.0 Functionality", {
expect_named(deleted_records, c("sf__Id", "sf__Created", "Id", "sf__Error"))
expect_equal(nrow(deleted_records), length(ids_to_delete))
expect_true(all(is.na(deleted_records$sf__Error)))
expect_true(all(deleted_records$sf__Created == "false"))
expect_true(all(!deleted_records$sf__Created))
})
16 changes: 8 additions & 8 deletions tests/testthat/test-metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,39 +82,39 @@ test_that("sf_create_metadata", {
expect_is(custom_object_result, "tbl_df")
expect_named(custom_object_result, c('fullName', 'success'))
expect_equal(nrow(custom_object_result), 1)
expect_equal(custom_object_result$success, 'true')
expect_equal(all(custom_object_result$success))

expect_is(create_fields_result1, "tbl_df")
expect_named(create_fields_result1, c('fullName', 'success'))
expect_equal(nrow(create_fields_result1), 2)
expect_true(all(create_fields_result1$success == 'true'))
expect_true(all(create_fields_result1$success))

expect_is(create_fields_result2, "tbl_df")
expect_named(create_fields_result2, c('fullName', 'success'))
expect_equal(nrow(create_fields_result2), 2)
expect_true(all(create_fields_result2$success == 'true'))
expect_true(all(create_fields_result2$success))
})

test_that("sf_update_metadata", {
expect_is(updated_custom_object_result, "tbl_df")
expect_named(updated_custom_object_result, c('fullName', 'success'))
expect_equal(nrow(updated_custom_object_result), 1)
expect_equal(updated_custom_object_result$success, 'true')
expect_equal(all(updated_custom_object_result$success))
})

test_that("sf_rename_metadata", {
expect_is(renamed_custom_object_result, "tbl_df")
expect_named(renamed_custom_object_result, c('fullName', 'success'))
expect_equal(nrow(renamed_custom_object_result), 1)
expect_equal(renamed_custom_object_result$success, 'true')
expect_true(all(renamed_custom_object_result$success))
})

test_that("sf_upsert_metadata", {
expect_is(upserted_custom_object_result, "tbl_df")
expect_named(upserted_custom_object_result, c('created', 'fullName', 'success'))
expect_equal(nrow(upserted_custom_object_result), 2)
expect_true(all(upserted_custom_object_result$success == 'true'))
expect_equal(upserted_custom_object_result$created, c('false', 'true'))
expect_true(all(upserted_custom_object_result$success))
expect_equal(upserted_custom_object_result$created, c(FALSE, TRUE))
})

test_that("sf_describe_metadata", {
Expand Down Expand Up @@ -155,5 +155,5 @@ test_that("sf_delete_metadata", {
expect_is(deleted_custom_object_result, "tbl_df")
expect_named(deleted_custom_object_result, c('fullName', 'success'))
expect_equal(nrow(deleted_custom_object_result), 2)
expect_true(all(deleted_custom_object_result$success == 'true'))
expect_true(all(deleted_custom_object_result$success))
})

0 comments on commit 104080a

Please sign in to comment.