From 68fcf7278925403435d059319dedfa7154871688 Mon Sep 17 00:00:00 2001 From: Mary Jo Ramos Date: Thu, 17 Jun 2021 15:47:11 -0500 Subject: [PATCH] Update git tests to use Mocking --- src/plugins/git.jl | 2 +- test/git.jl | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/git.jl b/src/plugins/git.jl index 90911efd..b1f65b72 100644 --- a/src/plugins/git.jl +++ b/src/plugins/git.jl @@ -108,7 +108,7 @@ function posthook(p::Git, ::Template, pkg_dir::AbstractString) LibGit2.with(GitRepo(pkg_dir)) do repo LibGit2.add!(repo, ".") msg = "Files generated by PkgTemplates" - v = version_of("PkgTemplates") + v = @mock version_of("PkgTemplates") v === nothing || (msg *= "\n\nPkgTemplates version: $v") # TODO: Put the template config in the message too? commit(p, repo, pkg_dir, msg) diff --git a/test/git.jl b/test/git.jl index b5805203..7b5bfbb2 100644 --- a/test/git.jl +++ b/test/git.jl @@ -69,7 +69,9 @@ @testset "Adds version to commit message" begin # We're careful to avoid a Pkg.update as it triggers Cassette#130. t = tpl(; plugins=[Git(), !Tests]) - mock(PT.version_of => _p -> v"1.2.3") do _i + + patch = @patch PkgTemplates.version_of(t) = v"1.2.3" + apply(patch) do with_pkg(t) do pkg pkg_dir = joinpath(t.dir, pkg) LibGit2.with(GitRepo(pkg_dir)) do repo