PkgTemplates.jl/test/show.jl

52 lines
1.7 KiB
Julia
Raw Normal View History

2019-09-02 14:20:33 +00:00
const DEFAULTS_DIR = contractuser(PT.DEFAULTS_DIR)
const LICENSE_DIR = contractuser(joinpath(PT.DEFAULTS_DIR, "licenses"))
2019-09-02 14:20:33 +00:00
@testset "Show methods" begin
@testset "Plugins" begin
expected = """
Readme:
2019-09-19 00:58:48 +00:00
file: "$(joinpath(DEFAULTS_DIR, "README.md"))"
2019-09-02 14:20:33 +00:00
destination: "README.md"
inline_badges: false
"""
@test sprint(show, MIME("text/plain"), Readme()) == rstrip(expected)
2019-09-02 14:20:33 +00:00
end
@testset "Template" begin
expected = """
Template:
authors: ["$USER"]
develop: true
dir: "$(contractuser(Pkg.devdir()))"
2019-09-02 14:20:33 +00:00
git: true
host: "github.com"
julia_version: v"1.0.0"
manifest: false
ssh: false
user: "$USER"
plugins:
Gitignore:
ds_store: true
dev: true
License:
2019-09-19 00:58:48 +00:00
path: "$(joinpath(LICENSE_DIR, "MIT"))"
2019-09-02 14:20:33 +00:00
destination: "LICENSE"
Readme:
2019-09-19 00:58:48 +00:00
file: "$(joinpath(DEFAULTS_DIR, "README.md"))"
destination: "README.md"
inline_badges: false
Tests:
file: "$(joinpath(DEFAULTS_DIR, "test", "runtests.jl"))"
project: false
2019-09-02 14:20:33 +00:00
"""
@test sprint(show, MIME("text/plain"), tpl(; authors=USER)) == rstrip(expected)
end
@testset "show as serialization" begin
# Equality is not implemented for Template, so check the string form.
t1 = tpl()
t2 = eval(Meta.parse(sprint(show, t1)))
@test sprint(show, t1) == sprint(show, t2)
2019-09-02 14:20:33 +00:00
end
end