Skip to content

Commit

Permalink
modified test_cache to use safetestset
Browse files Browse the repository at this point in the history
  • Loading branch information
codingonsteroid committed Sep 20, 2020
1 parent 0bd2915 commit e27dd4a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ docs/build
.vscode
test/build
Manifest.toml
test/cache
test/sessions
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Genie = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
Expand Down
17 changes: 13 additions & 4 deletions test/tests_cache.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "Caching" begin
@safetestset "No Caching" begin
using Genie, Genie.Cache

function f()
Expand All @@ -9,7 +9,7 @@

r0 = f()

r1 = withcache(:x) do
r1 = withcache(:x) do
f()
end

Expand All @@ -20,9 +20,18 @@
end

@test r1 != r2 # because cache_duration == 0 so no caching
end


Genie.config.cache_duration = 5 # cache for 5s
@safetestset "cache" begin
using Genie, Genie.Cache

function f()
rand(1:1_000)
end

Genie.config.cache_duration = 5

r1 = withcache(:x) do
f()
end
Expand Down Expand Up @@ -58,4 +67,4 @@
end

@test r1 == r2 == r5 != r6
end;
end

0 comments on commit e27dd4a

Please sign in to comment.