Bugs in test on gitlab
tests
fix it, these errors are not observed on my computer update db, use a variable that tells skipping if not iav
-
Database connection -
Loading program -
Report mig - Test_an_instance_of_report_mig_check_that_operations_accross_two_years_are_split_correcly -
report mig - Test_writing_an_example_to_the_database -
report_mig - Test_that_different_sums_are_the_same_for_report_mig_report_mig_interannual_report_annual -
report-mig test_example_for_fd80 -
report_mig_interannual Test_supprime_method -
report_mig_interannual Test_bmi_for_several_dc -
report_mig_interannual Test_that_database_is_not_written_over_and_over -
report_mig_interannual Test_method_summary_when_data_are_not_every_month
Database connection
Error: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
Host is passed raw because at this stage options are not set ... aren't they really try without
test_that("Test that stacomirtools connects",{
skip_on_cran()
env_set_test_stacomi()
envir_stacomi <- new.env(parent = asNamespace("stacomiR"))
con <- new("ConnectionDB")
con@dbname <- "bd_contmig_nat"
con@host <- "localhost"
con@port <- "5432"
con@user <- getOption("stacomiR.user", default="postgres")
con@password <- getOption("stacomiR.password", default="postgres")
con <- connect(con)
expect_is(connect(con),'ConnectionDB')
expect_equal(con@status,"Connection OK")
pool::poolClose(con@connection)
rm("envir_stacomi")
}
)
"Loading program"
There is no schema logrami in the test db
test_that("Test get_schema",{
skip_on_cran()
env_set_test_stacomi()
stacomi(database_expected=TRUE)
sch <- get_schema()
expect_equal(sch,"iav.")
rm("sch", envir=envir_stacomi)
sch <- get_schema(default="volga.")
expect_equal(sch,"volga.")
stacomi(database_expected = TRUE, sch = "logrami")
sch <- get_schema()
expect_equal(sch,"logrami.")
org <- get_org()
expect_equal(org,"LOGRAMI")
})
report mig - Test_an_instance_of_report_mig_check_that_operations_accross_two_years_are_split_correcly
??
<testsuite name="report_mig" timestamp="2022-08-22T10:16:33Z" hostname="runner-h7evdmcs-project-4584-concurrent-1" tests="14" skipped="0" failures="1" errors="3" time="4.731">
<testcase time="0.287999999999997" classname="report_mig" name="Test_an_instance_of_report_mig"/>
<testcase time="0.575000000000003" classname="report_mig" name="Test_an_instance_of_report_mig_check_that_operations_accross_two_years_are_split_correcly">
<failure type="failure" message="round(sum(report_mig@calcdata[["dc_6"]][["data"]]$Effectif_total)) not equal to 8613. (test-02-report_mig.R:48:4)"
>round(sum(report_mig@calcdata[["dc_6"]][["data"]]$Effectif_total)) not equal to 8613.
1/1 mismatches
[1] 8614 - 8613 == 1</failure>
report mig - "Test_writing_an_example_to_the_database"
this one will be fixed on the db by uploading a new version of the db
<error type="error" message="<Rcpp::exception/C++Error/error/condition> (test-02-report_mig.R:146:4)"><Rcpp::exception/C++Error/error/condition>
Error: Failed to fetch row: ERREUR: la valeur d'une clé dupliquée rompt la contrainte unique « c_pk_bme »
DETAIL: La clé « (bme_identifiant, bme_org_code)=(8345, IAV) » existe déjà.
Backtrace:
1. testthat::expect_output(...)
at test-02-report_mig.R:146:24
11. stacomiR::write_database(object = r_mig, silent = FALSE, check_for_bjo = FALSE)
at stacomir/R/create_generic.R:57:35
12. stacomiR (local) .local(object, ...)
13. stacomiR (local) confirm()
at stacomir/R/report_mig.R:925:32
14. stacomiR::fun_write_monthly(report_mig, resum, silent = silent)
at stacomir/R/report_mig.R:900:32
16. pool::dbExecute(con@connection, statement = sql)
18. DBI::dbExecute(connection, statement, ...)
20. DBI::dbSendStatement(conn, statement, ...)
22. RPostgres::dbSendQuery(conn, statement, ...)
23. RPostgres (local) .local(conn, statement, ...)
27. RPostgres:::result_create(conn@ptr, statement, immediate)</error>
report_mig - Test_that_different_sums_are_the_same_for_report_mig_report_mig_interannual_report_annual
same as before
Error: Failed to fetch row: ERREUR: la valeur d'une clé dupliquée rompt la contrainte unique « c_pk_bme »
DETAIL: La clé « (bme_identifiant, bme_org_code)=(8346, IAV) » existe déjà.
Backtrace:
1. stacomiR::write_database(object = r_mig, silent = TRUE)
at test-02-report_mig.R:163:24
2. stacomiR::write_database(object = r_mig, silent = TRUE)
at stacomir/R/create_generic.R:57:35
3. stacomiR (local) .local(object, ...)
4. stacomiR (local) confirm()
at stacomir/R/report_mig.R:922:40
5. stacomiR::fun_write_monthly(report_mig, resum, silent = silent)
at stacomir/R/report_mig.R:900:32
7. pool::dbExecute(con@connection, statement = sql)
9. DBI::dbExecute(connection, statement, ...)
11. DBI::dbSendStatement(conn, statement, ...)
13. RPostgres::dbSendQuery(conn, statement, ...)
14. RPostgres (local) .local(conn, statement, ...)
18. RPostgres:::result_create(conn@ptr, statement, immediate)</error>
report-mig test_example_for_fd80
The absence of schema triggers an uninterpretable error, seems there is no arret check this too !
<error type="error"
message="Error in `if (arret) stop(text) else print(text, quote = FALSE, ...)`: argument is not interpretable as logical (test-02-report_mig.R:204:4)">Error in `if (arret) stop(text) else print(text, quote = FALSE, ...)`: argument is not interpretable as logical
Backtrace:
1. stacomiR::stacomi(database_expected = TRUE, sch = "fd80")
at test-02-report_mig.R:204:24
2. stacomiR:::load_stacomi()
at stacomir/R/stacomi.R:124:8
3. stacomiR:::funout(...)
at stacomir/R/stacomi.R:61:32</error>
report_mig_interannual Test_supprime_method
logrami is not there and the message needs fixing
<testcase time="0.0489999999999995" classname="report_mig_interannual" name="Test_supprime_method">
<error type="error" message="Error in `if (arret) stop(text) else print(text, quote = FALSE, ...)`: argument is not interpretable as logical (test-06-report_mig_interannual.R:134:4)">Error in `if (arret) stop(text) else print(text, quote = FALSE, ...)`: argument is not interpretable as logical
Backtrace:
1. stacomiR::stacomi(database_expected = TRUE, sch = "logrami")
at test-06-report_mig_interannual.R:134:24
2. stacomiR:::load_stacomi()
at stacomir/R/stacomi.R:124:8
3. stacomiR:::funout(...)
at stacomir/R/stacomi.R:61:32</error>
report_mig_interannual Test_bmi_for_several_dc
Another db pb (bme)
<error type="error" message="<Rcpp::exception/C++Error/error/condition> (test-06-report_mig_interannual.R:249:4)"><Rcpp::exception/C++Error/error/condition>
Error: Failed to fetch row: ERREUR: la valeur d'une clé dupliquée rompt la contrainte unique « c_pk_bme »
DETAIL: La clé « (bme_identifiant, bme_org_code)=(8347, IAV) » existe déjà.
Backtrace:
1. stacomirtools::connect(r_mig_interannual, silent = TRUE)
at test-06-report_mig_interannual.R:249:24
2. stacomiR (local) connect(r_mig_interannual, silent = TRUE)
3. stacomiR (local) .local(object, ...)
5. stacomiR::write_database(bM, silent = silent, check_for_bjo = FALSE)
at stacomir/R/create_generic.R:57:35
6. stacomiR (local) .local(object, ...)
7. stacomiR (local) confirm()
at stacomir/R/report_mig.R:925:32
8. stacomiR::fun_write_monthly(report_mig, resum, silent = silent)
at stacomir/R/report_mig.R:900:32
10. pool::dbExecute(con@connection, statement = sql)
12. DBI::dbExecute(connection, statement, ...)
14. DBI::dbSendStatement(conn, statement, ...)
16. RPostgres::dbSendQuery(conn, statement, ...)
17. RPostgres (local) .local(conn, statement, ...)
21. RPostgres:::result_create(conn@ptr, statement, immediate)</error>
report_mig_interannual Test_that_database_is_not_written_over_and_over
Another db pb (update data to 2021)
<testcase time="0.536000000000001" classname="report_mig_interannual" name="Test_that_database_is_not_written_over_and_over">
<failure type="failure" message="`r_mig_interannual <- connect\(r_mig_interannual, silent = TRUE\)` does not match "No writing in the db.". (test-06-report_mig_interannual.R:286:4)">`r_mig_interannual <- connect\(r_mig_interannual, silent = TRUE\)` does not match "No writing in the db.".
Actual value: "\[1\] No data in table t_bilanmigrationjournalier_bjo\\n\[1\] There are no values for the taxa, stage and selected period\\\\n"
Backtrace:
1. testthat::expect_output(...)
at test-06-report_mig_interannual.R:286:24
2. testthat::expect_match(...)
3. testthat:::expect_match_(...)</failure>
report_mig_interannual Test_method_summary_when_data_are_not_every_month
Another db pb
<testcase time="0.730000000000004" classname="report_mig_interannual" name="Test_method_summary_when_data_are_not_every_month">
<error type="error" message="<Rcpp::exception/C++Error/error/condition> (test-06-report_mig_interannual.R:311:4)"><Rcpp::exception/C++Error/error/condition>
Error: Failed to fetch row: ERREUR: la valeur d'une clé dupliquée rompt la contrainte unique « c_pk_bme »
DETAIL: La clé « (bme_identifiant, bme_org_code)=(8348, IAV) » existe déjà.
Backtrace:
1. utils::capture.output(rmi <- connect(rmi, silent = TRUE))
at test-06-report_mig_interannual.R:311:24
4. stacomiR (local) connect(rmi, silent = TRUE)
5. stacomiR (local) .local(object, ...)
7. stacomiR::write_database(bM, silent = silent, check_for_bjo = FALSE)
at stacomir/R/create_generic.R:57:35
8. stacomiR (local) .local(object, ...)
9. stacomiR (local) confirm()
at stacomir/R/report_mig.R:925:32
10. stacomiR::fun_write_monthly(report_mig, resum, silent = silent)
at stacomir/R/report_mig.R:900:32
12. pool::dbExecute(con@connection, statement = sql)
14. DBI::dbExecute(connection, statement, ...)
16. DBI::dbSendStatement(conn, statement, ...)
18. RPostgres::dbSendQuery(conn, statement, ...)
19. RPostgres (local) .local(conn, statement, ...)
23. RPostgres:::result_create(conn@ptr, statement, immediate)</error>
all other errors the same