tests/testthat/test-getLocation.R

test_that("getLocation function returns a data frame", {
  df <- getLocation(CERT = 3850, fields = c("NAME","CITY","STNAME"), limit = 1000)
  expect_is(df, "data.frame")
})

test_that("getLocation function returns NULL if CERT parameter is missing", {
  expect_error(getLocation(fields = c("NAME","CITY","STNAME"), limit = 1000))

})

test_that("getLocation function returns data in the correct format and structure", {
  df <- getLocation(CERT = 3850, fields = c("NAME","CITY","STNAME"), limit = 1000)
  expect_equal(ncol(df), 6)
  expect_gte(nrow(df), 0)
  if(nrow(df) > 0){
    expect_type(df$NAME, "character")
    expect_type(df$CITY, "character")
    expect_type(df$STNAME, "character")
    expect_type(df$MAINOFF, "integer")
    expect_type(df$CERT, "integer")
  }
})

Try the fdicdata package in your browser

Any scripts or data that you put into this service are public.

fdicdata documentation built on Sept. 12, 2024, 5:08 p.m.