tests/testthat/test-format.R

test_that("format.gitcreds", {
  cred <- gitcreds$new_gitcreds(
    protocol = "https",
    host = "github.com",
    username = "user",
    password = "secret",
    arbitrary = "xxxxxxxxx"
  )

  fmt <- format(cred)
  expect_true(any(grepl("arbitrary", fmt, fixed = TRUE)))
  expect_true(any(grepl("xxxxxx", fmt, fixed = TRUE)))
  expect_false(any(grepl("secret", fmt, fixed = TRUE)))
  expect_true(any(grepl("hidden", fmt, fixed = TRUE)))
})

test_that("print.gitcreds", {
  cred <- gitcreds$new_gitcreds(
    protocol = "https",
    host = "github.com",
    username = "user",
    password = "secret",
    arbitrary = "xxxxxxxxx"
  )

  out <- capture.output(ret <- print(cred))
  expect_equal(ret, cred)
  expect_true(any(grepl("arbitrary", out, fixed = TRUE)))
  expect_true(any(grepl("xxxxxx", out, fixed = TRUE)))
  expect_false(any(grepl("secret", out, fixed = TRUE)))
  expect_true(any(grepl("hidden", out, fixed = TRUE)))
})

Try the gitcreds package in your browser

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

gitcreds documentation built on Sept. 8, 2022, 5:08 p.m.