R Under development (unstable) (2023-10-03 r85259 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(WebAnalytics) Loading required package: ggplot2 Loading required package: xtable Loading required package: data.table Loading required package: scales > > test_that("missing Software line detected", { + expect_error(logFileFieldsGetIIS("u_getIISFields2.log"), 'log file does not appear to be an IIS log,') + }) Test passed 😀 > test_that("mismatched fields detected", { + expect_error(logFileFieldsGetIIS("u_getIISFields1.log"), 'more than one unique Field') + }) Test passed 🌈 > test_that("missing fields line detected", { + expect_error(logFileFieldsGetIIS("u_getIISFields3.log"), 'no Fields: specification') + }) Test passed 🥇 > test_that("field list construction failure detected", { + expect_error(logFileFieldsGetIIS("u_getIISFields4.log"), 'field list not constructed from Fields') + }) Test passed 🥇 > test_that("missing date detected", { + expect_error(logFileFieldsGetIIS("u_getIISFields6.log"), 'Fields specification does not include both date and time') + }) Test passed 🌈 > test_that("missing time detected", { + expect_error(logFileFieldsGetIIS("u_getIISFields7.log"), 'Fields specification does not include both date and time') + }) Test passed 🥳 > test_that("out of order date and time detected", { + expect_error(logFileFieldsGetIIS("u_getIISFields8.log"), 'Date and Time fields are not consecutive') + }) Test passed 🎊 > test_that("correct fields are emitted",{ + expect_equal(logFileFieldsGetIIS("u_getIISFields5.log"), 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 passed 🎊 > > proc.time() user system elapsed 3.25 0.34 3.57