Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start using vcr #2

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
tests/fixtures/**/* -diff
48 changes: 48 additions & 0 deletions .github/workflows/R-CMD-check-real-requests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- vcrtest
schedule:
- cron: '0 12 * * 1'

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release', vcrturnoff: 'true'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
VCR_TURN_OFF: ${{ matrix.config.vcrturnoff }}

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
17 changes: 9 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ Authors@R:
comment = c(ORCID = "0000-0002-2815-0399"))
Description: What the package does (one paragraph).
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
Imports:
httr,
purrr
Suggests:
testthat
testthat,
vcr (>= 0.6.0),
webmockr
Config/testthat/edition: 3
Imports:
purrr,
httr
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.2
2 changes: 1 addition & 1 deletion R/organizations.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ gh_organizations <- function(since = 1) {
httr::add_headers("Authorization" = paste("token", token))
)

httr::stop_for_status(response)
httr::stop_for_status(response, task = "get data from the API, oops")

content <- httr::content(response)

Expand Down
58 changes: 58 additions & 0 deletions tests/fixtures/gh_api_status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
http_interactions:
- request:
method: get
uri: https://kctbh9vrtdwd.statuspage.io/api/v2/components.json
body:
encoding: ''
string: ''
headers:
Accept: application/json, text/xml, application/xml, */*
Authorization: My bearer token is safe
response:
status:
status_code: 200
category: Success
reason: OK
message: 'Success: (200) OK'
headers:
vary: Accept,Accept-Encoding,Fastly-SSL
cache-control: max-age=0, private, must-revalidate
x-cache: MISS
content-type: application/json; charset=utf-8
content-encoding: gzip
strict-transport-security: max-age=259200
date: Mon, 14 Dec 2020 13:36:27 GMT
x-request-id: 1e2b60ce-b2e9-4511-8a54-2bc081178583
x-download-options: noopen
x-xss-protection: 1; mode=block
x-runtime: '0.039658'
x-permitted-cross-domain-policies: none
access-control-allow-origin: '*'
accept-ranges: bytes
x-content-type-options: nosniff
etag: W/"gz[fd28ddd5c0e61f8f9ef06b9211fefcdd]"
x-statuspage-skip-logging: 'true'
x-statuspage-version: 4639ace0759d8bd9ebdda5d4637cc1b43b8e8d62
referrer-policy: strict-origin-when-cross-origin
age: '0'
body:
encoding: UTF-8
file: no
string: '{"page":{"id":"kctbh9vrtdwd","name":"GitHub","url":"https://www.githubstatus.com","time_zone":"Etc/UTC","updated_at":"2020-12-14T08:04:41.926Z"},"components":[{"id":"8l4ygp009s5s","name":"Git
Operations","status":"operational","created_at":"2017-01-31T20:05:05.370Z","updated_at":"2020-10-29T22:51:43.831Z","position":1,"description":"Performance
of git clones, pulls, pushes, and associated operations","showcase":false,"start_date":null,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false},{"id":"brv1bkgrwx7q","name":"API
Requests","status":"operational","created_at":"2017-01-31T20:01:46.621Z","updated_at":"2020-10-30T22:01:20.086Z","position":2,"description":"Requests
for GitHub APIs","showcase":false,"start_date":null,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false},{"id":"4230lsnqdsld","name":"Webhooks","status":"operational","created_at":"2019-11-13T18:00:24.256Z","updated_at":"2020-11-18T23:38:14.467Z","position":3,"description":"Real
time HTTP callbacks of user-generated and system events","showcase":false,"start_date":null,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false},{"id":"0l2p9nhqnxpd","name":"Visit
www.githubstatus.com for more information","status":"operational","created_at":"2018-12-05T19:39:40.838Z","updated_at":"2020-04-02T21:56:21.954Z","position":4,"description":null,"showcase":false,"start_date":null,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false},{"id":"kr09ddfgbfsf","name":"Issues","status":"operational","created_at":"2017-01-31T20:01:46.638Z","updated_at":"2020-11-18T23:36:59.799Z","position":5,"description":"Requests
for Issues on GitHub.com","showcase":false,"start_date":null,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false},{"id":"hhtssxt0f5v2","name":"Pull
Requests","status":"operational","created_at":"2020-09-02T15:39:06.329Z","updated_at":"2020-11-18T23:36:47.289Z","position":6,"description":"Requests
for Pull Requests on GitHub.com","showcase":false,"start_date":null,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false},{"id":"br0l2tvcx85d","name":"GitHub
Actions","status":"operational","created_at":"2019-11-13T18:02:19.432Z","updated_at":"2020-12-01T22:33:58.390Z","position":7,"description":"Workflows,
Compute and Orchestration for GitHub Actions","showcase":false,"start_date":null,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false},{"id":"st3j38cctv9l","name":"GitHub
Packages","status":"operational","created_at":"2019-11-13T18:02:40.064Z","updated_at":"2020-09-08T15:50:32.845Z","position":8,"description":"API
requests and webhook delivery for GitHub Packages","showcase":false,"start_date":null,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false},{"id":"vg70hn9s2tyj","name":"GitHub
Pages","status":"operational","created_at":"2017-01-31T20:04:33.923Z","updated_at":"2020-10-10T00:02:38.220Z","position":9,"description":"Frontend
application and API servers for Pages builds","showcase":false,"start_date":null,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false}]}'
recorded_at: 2020-12-14 13:36:27 GMT
recorded_with: vcr/0.6.0, webmockr/0.7.4
Loading