PkgTemplates.jl/test/show.jl

62 lines
2.0 KiB
Julia
Raw Normal View History

const TEMPLATES_DIR = contractuser(PT.TEMPLATES_DIR)
const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses")
2019-09-02 14:20:33 +00:00
@testset "Show methods" begin
@testset "Plugins" begin
expected = """
Readme:
file: "$(joinpath(TEMPLATES_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: ["Chris de Graaf <chrisadegraaf@gmail.com>"]
dir: "~/.local/share/julia/dev"
host: "github.com"
2019-09-25 13:48:39 +00:00
julia: v"1.0.0"
user: "$USER"
plugins:
"""
2019-09-02 14:20:33 +00:00
expected = """
Template:
authors: ["$USER"]
dir: "$(contractuser(Pkg.devdir()))"
2019-09-02 14:20:33 +00:00
host: "github.com"
2019-09-25 13:48:39 +00:00
julia: v"1.0.0"
2019-09-02 14:20:33 +00:00
user: "$USER"
plugins:
Git:
ignore: String[]
ssh: false
manifest: false
gpgsign: false
2019-09-02 14:20:33 +00:00
License:
path: "$(joinpath(LICENSES_DIR, "MIT"))"
2019-09-02 14:20:33 +00:00
destination: "LICENSE"
2019-09-20 02:31:56 +00:00
ProjectFile
Readme:
file: "$(joinpath(TEMPLATES_DIR, "README.md"))"
destination: "README.md"
inline_badges: false
SrcDir:
file: "$(joinpath(TEMPLATES_DIR, "src", "module.jl"))"
Tests:
file: "$(joinpath(TEMPLATES_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