tests/testthat/test-user_id.R

test_that("screen_name has print and [ methods", {
  x <- as_screenname("123456")
  expect_s3_class(x[1], "rtweet_screen_name")
  expect_snapshot(x)
})

test_that("user_type handles simple cases", {
  expect_equal(user_type("hadleywickham"), "screen_name")

  expect_equal(user_type(123), "user_id")
  expect_equal(user_type(bit64::as.integer64(123)), "user_id")
  expect_equal(user_type("123"), "user_id")
  expect_equal(user_type(as_screenname("123")), "screen_name")

  expect_error(user_type(TRUE),
               "`user` must be a screen name or user id")
})

Try the rtweet package in your browser

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

rtweet documentation built on Oct. 17, 2023, 1:11 a.m.