From 0631dc6be62d0d579ad70e84cd9d15f8277e9de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Besan=C3=A7on?= Date: Tue, 14 May 2019 21:31:34 +0200 Subject: [PATCH] tests passing --- src/PkgTemplates.jl | 3 ++- src/plugins/citation.jl | 2 +- test/plugins/citation.jl | 29 +++++++++++++++++++++++++++++ test/tests.jl | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 test/plugins/citation.jl diff --git a/src/PkgTemplates.jl b/src/PkgTemplates.jl index 3972653..1adadac 100644 --- a/src/PkgTemplates.jl +++ b/src/PkgTemplates.jl @@ -24,7 +24,8 @@ export TravisCI, GitLabCI, Codecov, - Coveralls + Coveralls, + Citation """ A plugin to be added to a [`Template`](@ref), which adds some functionality or integration. diff --git a/src/plugins/citation.jl b/src/plugins/citation.jl index 233c55f..ce3a07a 100644 --- a/src/plugins/citation.jl +++ b/src/plugins/citation.jl @@ -31,7 +31,7 @@ interactive(::Type{Citation}) = interactive(Citation; readme_section=false) function gen_plugin(p::Citation, t::Template, pkg_name::AbstractString) pkg_dir = joinpath(t.dir, pkg_name) text = """@misc{$pkg_name.jl, - \tauthor = {{$(t.author)}},\n + \tauthor = {{$(t.authors)}},\n \ttitle = {{$(pkg_name).jl}},\n \turl = {https://$(t.host)/$(t.user)/$(pkg_name).jl},\n \tversion = {v0.0.1},\n diff --git a/test/plugins/citation.jl b/test/plugins/citation.jl new file mode 100644 index 0000000..7d02806 --- /dev/null +++ b/test/plugins/citation.jl @@ -0,0 +1,29 @@ +t = Template(; user=me) +pkg_dir = joinpath(t.dir, test_pkg) + +@testset "CITATION" begin + @testset "Plugin creation" begin + p = Citation() + @test isempty(p.gitignore) + @test p.dest == "CITATION.bib" + @test isempty(p.badges) + @test isempty(p.view) + @test !p.readme_section + p = Citation(; readme_section=true) + @test p.readme_section + end + + @testset "File generation" begin + # Without a coverage plugin in the template, there should be no post-test step. + p = Citation() + @test gen_plugin(p, t, test_pkg) == ["CITATION.bib"] + @test isfile(joinpath(pkg_dir, "CITATION.bib")) + citation = read(joinpath(pkg_dir, "CITATION.bib"), String) + + @test occursin("@misc", citation) + @test occursin("$(t.authors)", citation) + @test occursin("v0.0.1", citation) + end +end + +rm(pkg_dir; recursive=true) diff --git a/test/tests.jl b/test/tests.jl index 142cba5..37c7ada 100644 --- a/test/tests.jl +++ b/test/tests.jl @@ -445,6 +445,7 @@ end include(joinpath("plugins", "coveralls.jl")) include(joinpath("plugins", "githubpages.jl")) include(joinpath("plugins", "gitlabpages.jl")) + include(joinpath("plugins", "citation.jl")) end @testset "Documenter add kwargs" begin