Skip to content

Commit 0634b7d

Browse files
committed
More robust test for comparing rerouting actions.
This is necessary given that the order of actions seems to change randomly; presumably this depends on Go's hashmap implementation.
1 parent 9c70199 commit 0634b7d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/testthat/test-rerouteLinks.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ uploadDirectory("test", "simple", "v1", src, staging=info$staging, url=info$url)
1111
uploadDirectory("test", "simple", "v2", src, staging=info$staging, url=info$url)
1212
uploadDirectory("test", "simple", "v3", src, staging=info$staging, url=info$url)
1313

14+
.sort_array_of_actions <- function(x) {
15+
x <- x[order(x$path),]
16+
rownames(x) <- NULL
17+
x
18+
}
19+
1420
test_that("rerouting functions work as expected", {
1521
actions <- rerouteLinks(list(list(project="test", asset="simple", version="v1")), staging=info$staging, url=info$url, dry.run=TRUE)
1622
expect_true(all("test/simple/v1/foo" == actions$source))
@@ -21,6 +27,6 @@ test_that("rerouting functions work as expected", {
2127
expect_true(Sys.readlink(file.path(info$registry, "test/simple/v2/foo")) != "")
2228

2329
actions2 <- rerouteLinks(list(list(project="test", asset="simple", version="v1")), staging=info$staging, url=info$url)
24-
expect_identical(actions, actions2)
30+
expect_identical(.sort_array_of_actions(actions), .sort_array_of_actions(actions2))
2531
expect_true(Sys.readlink(file.path(info$registry, "test/simple/v2/foo")) == "")
2632
})

0 commit comments

Comments
 (0)