Skip to content

Commit

Permalink
Reuse existing tests for input_file_name
Browse files Browse the repository at this point in the history
  • Loading branch information
zero323 committed May 2, 2017
1 parent cb7f2d6 commit 38f43d0
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions R/pkg/inst/tests/testthat/test_sparkSQL.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 38f43d0

Please sign in to comment.