tests/testthat/test-adl_dir_ls.R

library(dplyr)
skip_if_no_auth <- function() {
  if (identical(Sys.getenv("client_id"), "") || identical(Sys.getenv("client_secret"), "") || identical(Sys.getenv("tenant"), "")) {
    skip("No authentication available")
  }
}

context("ADL Directory List - More Than One Item In Directory")
test_that("file extension is correct",{

  # set token if authentication is possible
  if(identical(Sys.getenv("client_id"), "")){NULL
  }else{
    # set token
    set_adl_token(tenant = Sys.getenv("tenant"), client_id = Sys.getenv("client_id"), client_secret = Sys.getenv("client_secret"))
  }

  # if not authentication is available then skip tests
  skip_if_no_auth()
  dirs <- adl_dir_ls(Sys.getenv("adl_file_dir_correct"))
  expect_false(length(dirs) <= 1)
})

context("ADL Directory List - Read One Of The Paths")
test_that("file extension is correct",{

  # set token if authentication is possible
  if(identical(Sys.getenv("client_id"), "")){NULL
  }else{
    # set token
    set_adl_token(tenant = Sys.getenv("tenant"), client_id = Sys.getenv("client_id"), client_secret = Sys.getenv("client_secret"))
  }

  # if not authentication is available then skip tests
  skip_if_no_auth()
  dirs <- adl_dir_ls(Sys.getenv("adl_file_dir_correct"))
  df <- read_adl_delim(dirs[1], delim = ",")
  expect_vector(df)
  })
alexhallam/flyrod documentation built on Nov. 20, 2019, 7:33 a.m.