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

fix: task returned from content_render missing task_id #339

Merged
merged 6 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
`user_role` parameters. For example, this allows you to find all licensed
users on a Connect server. (#311)

## Minor improvements and fixes

- The task returned by `content_render()` now has the expected `task_id`
parameter and is able to be polled. (#338)

# connectapi 0.4.0

## New features
Expand Down
1 change: 0 additions & 1 deletion R/parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ tzone <- function(x) {
attr(x, "tzone")[[1]] %||% ""
}


new_datetime <- function(x = double(), tzone = "") {
tzone <- tzone %||% ""
if (is.integer(x)) {
Expand Down
5 changes: 3 additions & 2 deletions R/variant.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ VariantTask <- R6::R6Class(
#' @param task The task data.
initialize = function(connect, content, key, task) {
super$initialize(connect = connect, content = content, key = key)
# TODO: need to validate task (needs task_id)
if (is.null(task$task_id)) {
task$task_id <- task$id
}
self$task <- task
},
#' @description Return the underlying task.
Expand Down Expand Up @@ -302,7 +304,6 @@ variant_render <- function(variant) {
validate_R6_class(variant, "Variant")

rendered <- variant$render()
rendered$task_id <- rendered$id

VariantTask$new(connect = variant$get_connect(), content = variant$get_content(), key = variant$key, task = rendered)
}
Expand Down
9 changes: 9 additions & 0 deletions tests/integrated/test-content.R
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,15 @@ test_that("variant_render works", {
suppressMessages(poll_task(rnd2))
})

test_that("content_render works", {
rnd <- content_render(rmd_content)

expect_true(validate_R6_class(rnd, "VariantTask"))

# wait for tasks to complete...
suppressMessages(poll_task(rnd))
})

test_that("get_variant_renderings works", {
scoped_experimental_silence()

Expand Down
Loading