CirrusCI tests

This commit is contained in:
Chris de Graaf 2019-01-03 11:18:01 -06:00 committed by Chris de Graaf
parent 3db77fb865
commit 192caf818e
2 changed files with 55 additions and 0 deletions

54
test/plugins/cirrusci.jl Normal file
View File

@ -0,0 +1,54 @@
t = Template(; user=me)
pkg_dir = joinpath(t.dir, test_pkg)
@testset "CirrusCI" begin
@testset "Plugin creation" begin
p = CirrusCI()
@test isempty(p.gitignore)
@test p.src == joinpath(DEFAULTS_DIR, "cirrus.yml")
@test p.dest == ".cirrus.yml"
@test p.badges == [
Badge(
"Build Status",
"https://api.cirrus-ci.com/github/{{USER}}/{{PKGNAME}}.jl.svg",
"https://cirrus-ci.com/github/{{USER}}/{{PKGNAME}}.jl",
),
]
@test isempty(p.view)
p = CirrusCI(; config_file=nothing)
@test p.src === nothing
p = CirrusCI(; config_file=test_file)
@test p.src == test_file
@test_throws ArgumentError CirrusCI(; config_file=fake_path)
end
@testset "Badge generation" begin
p = CirrusCI()
@test badges(p, me, test_pkg) == ["[![Build Status](https://api.cirrus-ci.com/github/$me/$test_pkg.jl.svg)](https://cirrus-ci.com/github/$me/$test_pkg.jl)"]
end
@testset "File generation" begin
# Without a coverage plugin in the template, there should be no coverage step.
p = CirrusCI()
@test gen_plugin(p, t, test_pkg) == [".cirrus.yml"]
@test isfile(joinpath(pkg_dir, ".cirrus.yml"))
cirrus = read(joinpath(pkg_dir, ".cirrus.yml"), String)
@test !occursin("coverage_script", cirrus)
rm(joinpath(pkg_dir, ".cirrus.yml"))
# Generating the plugin with Codecov in the template should create a post-test step.
t.plugins[Codecov] = Codecov()
gen_plugin(p, t, test_pkg)
delete!(t.plugins, Codecov)
cirrus = read(joinpath(pkg_dir, ".cirrus.yml"), String)
@test occursin("coverage_script", cirrus)
@test occursin("cirrusjl coverage", cirrus)
rm(joinpath(pkg_dir, ".cirrus.yml"))
p = CirrusCI(; config_file=nothing)
@test isempty(gen_plugin(p, t, test_pkg))
@test !isfile(joinpath(pkg_dir, ".cirrus.yml"))
end
end
rm(pkg_dir; recursive=true)

View File

@ -441,6 +441,7 @@ end
include(joinpath("plugins", "travisci.jl"))
include(joinpath("plugins", "appveyor.jl"))
include(joinpath("plugins", "gitlabci.jl"))
include(joinpath("plugins", "cirrusci.jl"))
include(joinpath("plugins", "codecov.jl"))
include(joinpath("plugins", "coveralls.jl"))
include(joinpath("plugins", "githubpages.jl"))