tests/testthat/test-dbGetPlot.R

test_sgl_stmt <- "
  visualize
    hp as x,
    mpg as y
  from cars
  using points

  layer

  visualize
    carat as x,
    price as y
  from diamonds
  using points
"
test_plot <- dbGetPlot(test_con, test_sgl_stmt)

describe("dbGetPlot", {
  it("returns an instance of the sgl_plot class", {
    expect_equal(attr(test_plot, "class"), "sgl_plot")
  })
  it("only adds class attribute", {
    all_attributes <- names(attributes(test_plot))
    expect_setequal(all_attributes, c("names", "class"))
  })
  it("returns rgs with result dfs as base object", {
    rgs <- sgl_to_rgs(test_sgl_stmt)
    dfs <- result_dfs(rgs, test_con)
    expected <- rgs
    expected$result_dfs <- dfs

    expect_equal(
      unclass(test_plot),
      expected
    )
  })
})

Try the rsgl package in your browser

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

rsgl documentation built on June 9, 2026, 1:07 a.m.