Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic tests #11

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ version = "0.0.1+2023c"
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[compat]
TimeZones = "1"
julia = "1.6"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"

[targets]
test = ["Test"]
test = ["TimeZones", "Test"]
36 changes: 35 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
using TZJData
using TimeZones: TZJFile, TimeZone, Class
using Test

# TODO: Can be removed once this is in an official TimeZones release
Copy link
Member Author

@omus omus Aug 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The release this will be included in is TimeZones.jl 1.12.0 (JuliaTime/TimeZones.jl#441). Unfortunately, that release is blocked on a 1.0 release of this package which I'd like to have include these tests. We'll merge these tests as is.

function _reload_cache!(cache::AbstractDict, compiled_dir::AbstractString)
empty!(cache)
check = Tuple{String,String}[(compiled_dir, "")]

for (dir, partial) in check
for filename in readdir(dir)
startswith(filename, ".") && continue

path = joinpath(dir, filename)
name = isempty(partial) ? filename : join([partial, filename], "/")

if isdir(path)
push!(check, (path, name))
else
cache[name] = open(TZJFile.read, path, "r")(name)
end
end
end

return cache
end

@testset "TZJData.jl" begin
# Write your tests here.
@test isdir(TZJData.ARTIFACT_DIR)
@test occursin(r"^\d{4}[a-z]$", TZJData.TZDATA_VERSION)

@testset "load compiled" begin
cache = Dict{String,Tuple{TimeZone,Class}}()
_reload_cache!(cache, TZJData.ARTIFACT_DIR)
@test !isempty(cache)
end

# TODO: Check for changes to a `TimeZone`'s `Class` as a change from `Class(:STANDARD)`
# to `Class(:LEGACY)` can cause end-users code to break.
end