Add tests for show methods
This commit is contained in:
parent
c6f9e85b6c
commit
fb2c2e7429
@ -134,9 +134,9 @@ function show(io::IO, t::Template)
|
||||
println(io, "$spc→ Precompilation enabled: $(t.precompile ? "yes" : "no")")
|
||||
println(io, "$spc→ Minimum Julia version: v$(t.julia_version)")
|
||||
|
||||
print(io, "$spc→ Package dependencies: ")
|
||||
print(io, "$spc→ Package dependencies:")
|
||||
if isempty(t.requirements)
|
||||
println(io, "None")
|
||||
println(io, " None")
|
||||
else
|
||||
println(io)
|
||||
for req in sort(t.requirements)
|
||||
@ -144,9 +144,9 @@ function show(io::IO, t::Template)
|
||||
end
|
||||
end
|
||||
|
||||
print(io, "$spc→ Git configuration options: ")
|
||||
print(io, "$spc→ Git configuration options:")
|
||||
if isempty(t.gitconfig)
|
||||
println(io, "None")
|
||||
println(io, " None")
|
||||
else
|
||||
println(io)
|
||||
for k in sort(collect(keys(t.gitconfig)); by=string)
|
||||
@ -154,9 +154,9 @@ function show(io::IO, t::Template)
|
||||
end
|
||||
end
|
||||
|
||||
print(io, "$spc→ Plugins: ")
|
||||
print(io, "$spc→ Plugins:")
|
||||
if isempty(t.plugins)
|
||||
print(io, "None")
|
||||
print(io, " None")
|
||||
else
|
||||
for plugin in sort(collect(values(t.plugins)); by=string)
|
||||
println(io)
|
||||
|
@ -125,6 +125,71 @@ else
|
||||
info("Skipping tests that require TerminalMenus")
|
||||
end
|
||||
|
||||
@testset "Show methods" begin
|
||||
pkgdir = replace(joinpath(ENV["JULIA_PKGDIR"], "v$(version_floor())"), homedir(), "~")
|
||||
buf = IOBuffer()
|
||||
t = Template(; user=me, gitconfig=gitconfig)
|
||||
show(buf, t)
|
||||
text = String(take!(buf))
|
||||
expected = """
|
||||
Template:
|
||||
→ User: $me
|
||||
→ Host: github.com
|
||||
→ License: MIT
|
||||
→ Authors: $(gitconfig["user.name"])
|
||||
→ License years: 2017
|
||||
→ Package directory: $pkgdir
|
||||
→ Precompilation enabled: yes
|
||||
→ Minimum Julia version: v$VERSION
|
||||
→ Package dependencies: None
|
||||
→ Git configuration options:
|
||||
• github.user = $(gitconfig["github.user"])
|
||||
• user.email = $(gitconfig["user.email"])
|
||||
• user.name = $(gitconfig["user.name"])
|
||||
→ Plugins: None
|
||||
"""
|
||||
@test text == rstrip(expected)
|
||||
t = Template(
|
||||
user=me,
|
||||
license="",
|
||||
requirements=["Foo", "Bar"],
|
||||
gitconfig=gitconfig,
|
||||
plugins=[
|
||||
TravisCI(),
|
||||
CodeCov(),
|
||||
GitHubPages(),
|
||||
],
|
||||
)
|
||||
show(buf, t)
|
||||
text = String(take!(buf))
|
||||
expected = """
|
||||
Template:
|
||||
→ User: $me
|
||||
→ Host: github.com
|
||||
→ License: None
|
||||
→ Package directory: $pkgdir
|
||||
→ Precompilation enabled: yes
|
||||
→ Minimum Julia version: v$VERSION
|
||||
→ Package dependencies:
|
||||
• Bar
|
||||
• Foo
|
||||
→ Git configuration options:
|
||||
• github.user = $(gitconfig["github.user"])
|
||||
• user.email = $(gitconfig["user.email"])
|
||||
• user.name = $(gitconfig["user.name"])
|
||||
→ Plugins:
|
||||
• CodeCov:
|
||||
→ Config file: None
|
||||
→ 3 gitignore entries: "*.jl.cov", "*.jl.*.cov", "*.jl.mem"
|
||||
• GitHubPages:
|
||||
→ 0 asset files
|
||||
→ 2 gitignore entries: "/docs/build/", "/docs/site/"
|
||||
• TravisCI:
|
||||
→ Config file: Default
|
||||
→ 0 gitignore entries
|
||||
"""
|
||||
@test text == rstrip(expected)
|
||||
end
|
||||
|
||||
@testset "File generation" begin
|
||||
t = Template(;
|
||||
|
Loading…
Reference in New Issue
Block a user