diff --git a/tests/fixtures/DEMO.yml b/tests/fixtures/DEMO.yml new file mode 100644 index 0000000..86d638a --- /dev/null +++ b/tests/fixtures/DEMO.yml @@ -0,0 +1,46 @@ +http_interactions: +- request: + method: get + uri: http://ipinfo.io/ + body: + encoding: '' + string: '' + headers: + Accept: application/json, text/xml, application/xml, */* + response: + status: + status_code: 200 + category: Success + reason: OK + message: 'Success: (200) OK' + headers: + access-control-allow-origin: '*' + content-encoding: gzip + content-type: application/json; charset=utf-8 + date: Fri, 04 Oct 2024 01:00:32 GMT + referrer-policy: strict-origin-when-cross-origin + vary: Accept-Encoding + x-content-type-options: nosniff + x-frame-options: SAMEORIGIN + x-xss-protection: 1; mode=block + content-length: '247' + via: 1.1 google + strict-transport-security: max-age=2592000; includeSubDomains + body: + encoding: '' + file: no + string: |- + { + "ip": "redacted", + "hostname": "redacted", + "city": "Wellington", + "region": "Wellington Region", + "country": "NZ", + "loc": "-41.2866,174.7756", + "org": "redacted", + "postal": "6021", + "timezone": "Pacific/Auckland", + "readme": "https://ipinfo.io/missingauth" + } + recorded_at: 2024-10-04 01:00:32 GMT + recorded_with: vcr/1.6.0, webmockr/0.9.0 diff --git a/tests/testthat/helper-vcr.R b/tests/testthat/helper-vcr.R index b2abf49..8e8f767 100644 --- a/tests/testthat/helper-vcr.R +++ b/tests/testthat/helper-vcr.R @@ -1,6 +1,12 @@ library("vcr") # *Required* as vcr is set up on loading invisible(vcr::vcr_configure( filter_sensitive_data = list("<<>>" = Sys.getenv('EBIRD_KEY')), + # Remove sensitive information about tester from cassettes + filter_sensitive_data_regex = list( + '"ip": "redacted"' = '"ip": "[0-9.]+"', + '"hostname": "redacted"' = '"hostname": "[^"]*"', + '"org": "redacted"' = '"org": "[^"]*"' + ), dir = vcr::vcr_test_path("fixtures") )) vcr::check_cassette_names() diff --git a/tests/testthat/test-DEMO.R b/tests/testthat/test-DEMO.R new file mode 100644 index 0000000..021ef84 --- /dev/null +++ b/tests/testthat/test-DEMO.R @@ -0,0 +1,5 @@ +vcr::use_cassette("DEMO", { + test_that("DEMO", { + getlatlng() + }) +})