tests/testthat/test-FunctionReporter-network.R

context("FunctionReporter Expected Network Tests")
rm(list = ls())

##### RUN TESTS #####

for (testPkg in c('baseballstats', 'sartre', 'milne')) {
    test_that(sprintf('FunctionReporter extracts expected network for %s', testPkg), {

        testObj <- FunctionReporter$new()$set_package(testPkg)

        # Test nodes
        expect_equivalent(
            object = testObj$nodes
            , expected = data.table::fread(file.path(
                'testdata'
                , sprintf('%s_function_nodes.csv', testPkg)
                ))
            , ignore.col.order = TRUE
            , ignore.row.order = TRUE
        )

        # Test edges
        expect_equivalent(
            object = testObj$edges
            , expected = data.table::fread(
                file.path(
                    'testdata'
                    , sprintf('%s_function_edges.csv', testPkg)
                )
                , colClasses = c(SOURCE = "character", TARGET = "character")
            )
            , ignore.col.order = TRUE
            , ignore.row.order = TRUE
        )
    })
}

##### TEST TEAR DOWN #####

rm(list = ls())
closeAllConnections()

Try the pkgnet package in your browser

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

pkgnet documentation built on Dec. 23, 2021, 9:07 a.m.