library(testthat) library(WebAnalytics) test_that("expected record count is read",{ # it appears that skip in cran is not working. If skip doesn't work, remove the test skip() expect_true(59414 == nrow(logFileRead("u_getIISFields5.log", columnList = logFileFieldsGetIIS("u_getIISFields5.log")))) }) fullVarList = c("MSTimestamp","ignored: s-ip","httpop","url", "ignored: cs-uri-query","ignored: s-port","ignored: cs-username", "userip", "useragent", "ignored: cs(Referer)", "httpcode", "ignored: sc-substatus", "ignored: sc-win32-status", "elapsedms") test_that("minimum columns",{ # it appears that skip in cran is not working. If skip doesn't work, remove the test skip() #for(i in c(1,3,4,8,9,11,14)) #{ # expect_error(logFileRead("u_getIISFields5.log", columnList = fullVarList[-(i)]),"specified column set does not include a timestamp: ApacheTimestamp or MSTimestamp") #} expect_error(logFileRead("u_getIISFields5.log", columnList = fullVarList[-(1)]),"specified column set does not include a timestamp: ApacheTimestamp or MSTimestamp") expect_error(logFileRead("u_getIISFields5.log", columnList = fullVarList[-(4)]),"specified column set does not include all of the minimum required columns: url missing") expect_error(logFileRead("u_getIISFields5.log", columnList = fullVarList[-(11)]),"specified column set does not include all of the minimum required columns: httpcode missing") expect_error(logFileRead("u_getIISFields5.log", columnList = fullVarList[-(14)]),"specified column set does not include a duration: elapsedms, elaspedus, elapseds") expect_error(logFileRead("u_getIISFields5.log", columnList = fullVarList[-(3)]),"colClasses= is an unnamed vector of types, length 14, but there are 15 columns") expect_error(logFileRead("u_getIISFields5.log", columnList = fullVarList[-(8)]),"colClasses= is an unnamed vector of types, length 14, but there are 15 columns") expect_error(logFileRead("u_getIISFields5.log", columnList = fullVarList[-(9)]),"colClasses= is an unnamed vector of types, length 14, but there are 15 columns") tempVarList = fullVarList tempVarList[2] = "not a known variable" expect_error(logFileRead("u_getIISFields5.log", columnList = tempVarList),"column name \"not a known variable\" is neither a defined column name nor begins with the text 'ignore'") }) test_that("dropping ignore columns",{ # it appears that skip in cran is not working. If skip doesn't work, remove the test skip() # df = logFileRead("u_getIISFields5.log", columnList = fullVarList) # expect_false(any(grepl("ignore.*", names(df)))) }) test_that("report different column counts",{ # it appears that skip in cran is not working. If skip doesn't work, remove the test skip() expect_warning(any(grepl("ignore.*", names(logFileRead("u_getIISFields9.log", columnList = fullVarList))))) })