R Under development (unstable) (2023-09-30 r85239 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(testthat) > library(vndirect) > test_that("Get data for a valid ticker", { + # Replace 'TPB' with a valid ticker from your API + result <- getData(.tickers = "TPB", .size = 100) + + # Check if the result is a data frame + expect_is(result, "data.frame") + + # Add more specific expectations based on the structure of the result + # For example, check if specific columns exist or if certain values are present + }) [1] "code:TPB" Test passed 🥳 > > test_that("Get data for multiple tickers", { + # Replace with a list of valid tickers from your API + tickers <- c("TPB", "HPG", "SSI") + + result <- getData(.tickers = tickers, .size = 100) + + # Check if the result is a data frame + expect_is(result, "data.frame") + + # Add more specific expectations based on the structure of the result + # For example, check if specific columns exist or if certain values are present + }) [1] "code:TPB" [1] "code:HPG" [1] "code:SSI" Test passed 🎉 > > test_that("Get data for an invalid ticker", { + # Replace 'INVALID' with an invalid ticker to test error handling + expect_error(getData(.tickers = "INVALID", .size = 100), class = "error") + }) Test passed 🌈 > > test_that("Get data with missing tickers", { + # Test for missing .tickers parameter + expect_error(getData(.size = 100), class = "error") + }) Test passed 🎉 > > test_that("Get data with invalid size", { + # Test for .size <= 0 + expect_error(getData(.tickers = "TPB", .size = 0), class = "error") + }) Test passed 🥳 > > > proc.time() user system elapsed 1.45 0.23 3.34