From 192caf818e59cc0f49a0936c05d863d404da6c8a Mon Sep 17 00:00:00 2001 From: Chris de Graaf Date: Thu, 3 Jan 2019 11:18:01 -0600 Subject: [PATCH] CirrusCI tests --- test/plugins/cirrusci.jl | 54 ++++++++++++++++++++++++++++++++++++++++ test/tests.jl | 1 + 2 files changed, 55 insertions(+) create mode 100644 test/plugins/cirrusci.jl diff --git a/test/plugins/cirrusci.jl b/test/plugins/cirrusci.jl new file mode 100644 index 0000000..9efc1eb --- /dev/null +++ b/test/plugins/cirrusci.jl @@ -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) diff --git a/test/tests.jl b/test/tests.jl index 142cba5..b950c22 100644 --- a/test/tests.jl +++ b/test/tests.jl @@ -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"))