Add tests for manifest option

This commit is contained in:
Chris de Graaf 2018-11-07 14:46:44 -06:00
parent 5cf4954780
commit 973147639f
2 changed files with 37 additions and 7 deletions

View File

@ -1,6 +1,6 @@
@testset "Interactive mode" begin @testset "Interactive mode" begin
@testset "Template creation" begin @testset "Template creation" begin
write(stdin.buffer, "$me\n\n\r\n\n\nd") write(stdin.buffer, "$me\n\n\r\n\n\n\nd")
t = interactive_template() t = interactive_template()
@test t.user == me @test t.user == me
@test t.host == "github.com" @test t.host == "github.com"
@ -17,7 +17,7 @@
end end
down = '\x1b' * "[B" # Down array key. down = '\x1b' * "[B" # Down array key.
write(stdin.buffer, "$me\ngitlab.com\n$down\r$me\n$test_file\n0.5\nyes\n$down\r$down\rd\n\n") write(stdin.buffer, "$me\ngitlab.com\n$down\r$me\n$test_file\n0.5\nyes\nyes\n$down\r$down\rd\n\n")
t = interactive_template() t = interactive_template()
@test t.user == me @test t.user == me
@test t.host == "gitlab.com" @test t.host == "gitlab.com"
@ -27,6 +27,7 @@
@test t.dir == abspath(test_file) @test t.dir == abspath(test_file)
@test t.julia_version == v"0.5.0" @test t.julia_version == v"0.5.0"
@test t.ssh @test t.ssh
@test t.manifest
# Like above, not sure which plugins this will generate. # Like above, not sure which plugins this will generate.
@test length(t.plugins) == 2 @test length(t.plugins) == 2
@ -39,12 +40,13 @@
@test t.dir == default_dir @test t.dir == default_dir
@test t.julia_version == VERSION @test t.julia_version == VERSION
@test !t.ssh @test !t.ssh
@test !t.manifest
@test isempty(t.plugins) @test isempty(t.plugins)
println() println()
end end
@testset "Package generation" begin @testset "Package generation" begin
write(stdin.buffer, "$me\n\n\r\n\n\n\n\n\nd") write(stdin.buffer, "$me\n\n\r\n\n\n\n\n\n\nd")
generate_interactive(test_pkg; gitconfig=gitconfig) generate_interactive(test_pkg; gitconfig=gitconfig)
@test isdir(joinpath(default_dir, test_pkg)) @test isdir(joinpath(default_dir, test_pkg))
rm(joinpath(default_dir, test_pkg); force=true, recursive=true) rm(joinpath(default_dir, test_pkg); force=true, recursive=true)

View File

@ -45,6 +45,8 @@ write(test_file, template_text)
@test t.authors == LibGit2.getconfig("user.name", "") @test t.authors == LibGit2.getconfig("user.name", "")
@test t.dir == default_dir @test t.dir == default_dir
@test t.julia_version == VERSION @test t.julia_version == VERSION
@test !t.ssh
@test !t.manifest
@test isempty(t.plugins) @test isempty(t.plugins)
# Checking non-default field assignments. # Checking non-default field assignments.
@ -72,6 +74,12 @@ write(test_file, template_text)
t = Template(; user=me, julia_version=v"0.1.2") t = Template(; user=me, julia_version=v"0.1.2")
@test t.julia_version == v"0.1.2" @test t.julia_version == v"0.1.2"
t = Template(; user=me, ssh=true)
@test t.ssh
t = Template(; user=me, manifest=true)
@test t.manifest
# The template should contain whatever plugins you give it. # The template should contain whatever plugins you give it.
t = Template(; t = Template(;
user=me, user=me,
@ -114,6 +122,7 @@ end
Package directory: $pkg_dir Package directory: $pkg_dir
Minimum Julia version: v$(PkgTemplates.version_floor()) Minimum Julia version: v$(PkgTemplates.version_floor())
SSH remote: No SSH remote: No
Commit Manifest.toml: No
Plugins: None Plugins: None
""" """
@test text == rstrip(expected) @test text == rstrip(expected)
@ -121,6 +130,7 @@ end
user=me, user=me,
license="", license="",
ssh=true, ssh=true,
manifest=true,
plugins=[ plugins=[
TravisCI(), TravisCI(),
CodeCov(), CodeCov(),
@ -137,6 +147,7 @@ end
Package directory: $pkg_dir Package directory: $pkg_dir
Minimum Julia version: v$(PkgTemplates.version_floor()) Minimum Julia version: v$(PkgTemplates.version_floor())
SSH remote: Yes SSH remote: Yes
Commit Manifest.toml: Yes
Plugins: Plugins:
CodeCov: CodeCov:
Config file: None Config file: None
@ -186,10 +197,7 @@ end
gen_readme(pkg_dir, t) gen_readme(pkg_dir, t)
readme = readchomp(joinpath(pkg_dir, "README.md")) readme = readchomp(joinpath(pkg_dir, "README.md"))
rm(joinpath(pkg_dir, "README.md")) rm(joinpath(pkg_dir, "README.md"))
@test <( @test findfirst("coveralls", readme).start < findfirst("baz", readme).start
something(findfirst("coveralls", readme)).start,
something(findfirst("baz", readme)).start,
)
# Test the gitignore generation. # Test the gitignore generation.
@test gen_gitignore(pkg_dir, t) == [".gitignore"] @test gen_gitignore(pkg_dir, t) == [".gitignore"]
@ -285,6 +293,26 @@ end
generate(test_pkg, t; gitconfig=gitconfig) generate(test_pkg, t; gitconfig=gitconfig)
@test isdir(joinpath(temp_dir, test_pkg)) @test isdir(joinpath(temp_dir, test_pkg))
rm(temp_dir; recursive=true) rm(temp_dir; recursive=true)
# Check that the Manifest.toml is not commited by default.
t = Template(; user=me)
generate(test_pkg, t; gitconfig=gitconfig)
@test occursin("Manifest.toml", read(joinpath(pkg_dir, ".gitignore"), String))
# I'm not sure this is the "right" way to do this.
repo = GitRepo(pkg_dir)
idx = LibGit2.GitIndex(repo)
@test findall("Manifest.toml", idx) === nothing
rm(pkg_dir; recursive=true)
# And that it is when you tell it to be.
t = Template(; user=me, manifest=true)
generate(test_pkg, t; gitconfig=gitconfig)
@test !occursin("Manifest.toml", read(joinpath(pkg_dir, ".gitignore"), String))
# I'm not sure this is the "right" way to do this.
repo = GitRepo(pkg_dir)
idx = LibGit2.GitIndex(repo)
@test findall("Manifest.toml", idx) !== nothing
rm(pkg_dir; recursive=true)
end end
@testset "Version floor" begin @testset "Version floor" begin