test_that("creates commas separated string from vector", {
  expect_identical(
    parse_col_select(letters[1:5]),
    "a,b,c,d,e"
  )
})

test_that("returns NULL if input is NULL", {
  expect_null(parse_col_select(NULL))
})

test_that("Can deal with a list in some cases", {
  expect_identical(
    parse_col_select(list("col1", "col2")),
    "col1,col2"
  )
  expect_identical(
    parse_col_select(list(columns = c("col1", "col2"))),
    "col1,col2"
  )
  expect_identical(
    parse_col_select(list(
      columns = c("col1", "col2"),
      columns2 = c("col1", "col2")
    )),
    "col1,col2"
  )

  expect_error(parse_col_select(list(1:3)))
})

test_that("parse_col_select() removes duplicates and preserves order of first occurrence", {
  x <- c("A", "A", "B", "A", "C", "B")
  expect_identical(parse_col_select(x), "A,B,C")
})

test_that("errors on bad input", {
  expect_error(
    parse_col_select(1.0),
    "`col_select` must be a .+?character.+? vector, not a .+?numeric"
  )
  expect_error(
    parse_col_select(1L:3L),
    "`col_select` must be a .+?character.+? vector, not a .+?integer"
  )
  expect_error(
    parse_col_select(TRUE),
    "`col_select` must be a .+?character.+? vector, not a .+?logical"
  )
})
