Skip to content

Commit de0a348

Browse files
committed
Factor out list of dataset names in tests
Now only need to update one place when the list of test datasets changes.
1 parent 425c1b3 commit de0a348

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/ZipTree.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ close(r)
122122
#-------------------------------------------------------------------------------
123123

124124
# Fixes for ZipFile.jl
125-
# TODO: Upstream these!
125+
# TODO: Remove these once https://github.com/fhs/ZipFile.jl/pull/75 is in a release.
126126

127127
# It appears that ZipFile.jl just doesn't have a way to rewind to the start of
128128
# one of the embedded files.

test/projects.jl

+15-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ using DataSets:
88
StackedDataProject,
99
project_name
1010

11+
test_project_names = ["a_table",
12+
"a_text_file",
13+
"a_tree_example",
14+
"embedded_blob",
15+
"embedded_tree",
16+
"old_backend_blob",
17+
"old_backend_tree"]
18+
1119
@testset "TomlFileDataProject" begin
1220
proj = TomlFileDataProject(abspath("Data.toml"))
1321
# getindex, get
@@ -16,13 +24,13 @@ using DataSets:
1624
@test isnothing(get(proj, "nonexistent_data", nothing))
1725

1826
# keys
19-
@test sort(collect(keys(proj))) == ["a_table", "a_text_file", "a_tree_example", "embedded_blob", "embedded_tree", "old_backend_blob", "old_backend_tree"]
27+
@test sort(collect(keys(proj))) == test_project_names
2028
@test haskey(proj, "a_text_file")
2129
@test !haskey(proj, "nonexistent_data")
2230

2331
# iteration
24-
@test sort(getproperty.(collect(proj), :name)) == ["a_table", "a_text_file", "a_tree_example", "embedded_blob", "embedded_tree", "old_backend_blob", "old_backend_tree"]
25-
@test sort(first.(pairs(proj))) == ["a_table", "a_text_file", "a_tree_example", "embedded_blob", "embedded_tree", "old_backend_blob", "old_backend_tree"]
32+
@test sort(getproperty.(collect(proj), :name)) == test_project_names
33+
@test sort(first.(pairs(proj))) == test_project_names
2634

2735
# identity
2836
@test project_name(proj) == abspath("Data.toml")
@@ -99,7 +107,7 @@ end
99107
push!(proj, TomlFileDataProject(joinpath(@__DIR__, "active_project", "Data.toml")))
100108
push!(proj, TomlFileDataProject(joinpath(@__DIR__, "Data.toml")))
101109

102-
@test sort(collect(keys(proj))) == ["a_table", "a_text_file", "a_tree_example", "embedded_blob", "embedded_tree", "old_backend_blob", "old_backend_tree"]
110+
@test sort(collect(keys(proj))) == test_project_names
103111
# Data "a_text_file" should be found in the first project in the stack,
104112
# overriding the data of the same name in the second project.
105113
@test proj["a_text_file"].uuid == UUID("314996ef-12be-40d0-912c-9755af354fdb")
@@ -123,10 +131,9 @@ end
123131

124132
# Test that __init__ takes global DataSets.PROJECT from ENV
125133
empty!(DataSets.PROJECT)
126-
ENV["JULIA_DATASETS_PATH"] = datasets_paths
134+
ENV["JULIA_DATASETS_PATH"] = @__DIR__
127135
DataSets.__init__()
128-
@test DataSets.PROJECT.projects[1] isa ActiveDataProject
129-
@test DataSets.PROJECT.projects[2] isa TomlFileDataProject
130-
@test DataSets.PROJECT.projects[3] isa TomlFileDataProject
136+
@test DataSets.PROJECT.projects[1] isa TomlFileDataProject
137+
@test project_name(DataSets.PROJECT.projects[1]) == joinpath(@__DIR__, "Data.toml")
131138
end
132139

0 commit comments

Comments
 (0)