From 38f43d058df9a52eb1c1adc523b0a90c6e291ceb Mon Sep 17 00:00:00 2001 From: zero323 Date: Tue, 2 May 2017 08:09:23 +0200 Subject: [PATCH] Reuse existing tests for input_file_name --- R/pkg/inst/tests/testthat/test_sparkSQL.R | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/R/pkg/inst/tests/testthat/test_sparkSQL.R b/R/pkg/inst/tests/testthat/test_sparkSQL.R index 8bcc1a2dc1fd7..02161c9481ee8 100644 --- a/R/pkg/inst/tests/testthat/test_sparkSQL.R +++ b/R/pkg/inst/tests/testthat/test_sparkSQL.R @@ -1366,6 +1366,11 @@ test_that("column functions", { expect_equal(collect(df2)[[3, 1]], FALSE) expect_equal(collect(df2)[[3, 2]], TRUE) + # Test that input_file_name() + actual_names <- sort(collect(distinct(select(df, input_file_name())))) + expect_equal(length(actual_names), 1) + expect_equal(basename(actual_names[1, 1]), basename(jsonPath)) + df3 <- select(df, between(df$name, c("Apache", "Spark"))) expect_equal(collect(df3)[[1, 1]], TRUE) expect_equal(collect(df3)[[2, 1]], FALSE) @@ -1656,18 +1661,6 @@ test_that("greatest() and least() on a DataFrame", { expect_equal(collect(select(df, least(df$a, df$b)))[, 1], c(1, 3)) }) -test_that("input_file_name()", { - path <- tempfile(pattern = "input_file_name_test", fileext = ".txt") - write.table(iris[1:50, ], path, row.names = FALSE, col.names = FALSE) - - df <- read.text(path) - actual_names <- sort(collect(distinct(select(df, input_file_name())))) - expect_equal(length(actual_names), 1) - expect_equal(basename(actual_names[1, 1]), basename(path)) - - unlink(path) -}) - test_that("time windowing (window()) with all inputs", { df <- createDataFrame(data.frame(t = c("2016-03-11 09:00:07"), v = c(1))) df$window <- window(df$t, "5 seconds", "5 seconds", "0 seconds")