Replace Cassette mocking with SimpleMock
FYI: CI should fail until SimpleMock is finished being registered.
This commit is contained in:
parent
63f1f762a6
commit
5e843dadbb
@ -17,11 +17,11 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
|||||||
julia = "1"
|
julia = "1"
|
||||||
|
|
||||||
[extras]
|
[extras]
|
||||||
Cassette = "7057c7e9-c182-5462-911a-8362d720325c"
|
|
||||||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||||
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
|
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
|
||||||
|
SimpleMock = "a896ed2c-15a5-4479-b61d-a0e88e2a1d25"
|
||||||
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
|
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
|
||||||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
||||||
|
|
||||||
[targets]
|
[targets]
|
||||||
test = ["Cassette", "Suppressor", "Random", "ReferenceTests", "Test"]
|
test = ["Suppressor", "Random", "ReferenceTests", "SimpleMock", "Test"]
|
||||||
|
18
test/git.jl
18
test/git.jl
@ -1,9 +1,3 @@
|
|||||||
@context PTIsInstalled
|
|
||||||
function Cassette.posthook(::PTIsInstalled, result::Dict, ::typeof(Pkg.installed))
|
|
||||||
result["PkgTemplates"] = v"1.2.3"
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
@testset "Git repositories" begin
|
@testset "Git repositories" begin
|
||||||
@testset "Does not create Git repo" begin
|
@testset "Does not create Git repo" begin
|
||||||
t = tpl(; disable_defaults=[Git])
|
t = tpl(; disable_defaults=[Git])
|
||||||
@ -44,11 +38,13 @@ end
|
|||||||
@testset "Adds version to commit message" begin
|
@testset "Adds version to commit message" begin
|
||||||
# We're careful to avoid a Pkg.update as it triggers Cassette#130.
|
# We're careful to avoid a Pkg.update as it triggers Cassette#130.
|
||||||
t = tpl(; disable_defaults=[Tests], plugins=[Git()])
|
t = tpl(; disable_defaults=[Tests], plugins=[Git()])
|
||||||
@overdub PTIsInstalled() with_pkg(t) do pkg
|
mock(CTX, Pkg.installed => () -> Dict("PkgTemplates" => v"1.2.3")) do _pi
|
||||||
pkg_dir = joinpath(t.dir, pkg)
|
with_pkg(t) do pkg
|
||||||
LibGit2.with(GitRepo(pkg_dir)) do repo
|
pkg_dir = joinpath(t.dir, pkg)
|
||||||
commit = GitCommit(repo, "HEAD")
|
LibGit2.with(GitRepo(pkg_dir)) do repo
|
||||||
@test occursin("PkgTemplates version: 1.2.3", LibGit2.message(commit))
|
commit = GitCommit(repo, "HEAD")
|
||||||
|
@test occursin("PkgTemplates version: 1.2.3", LibGit2.message(commit))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,8 +5,8 @@ using Pkg: Pkg
|
|||||||
using Random: Random
|
using Random: Random
|
||||||
using Test: @test, @testset, @test_throws
|
using Test: @test, @testset, @test_throws
|
||||||
|
|
||||||
using Cassette: Cassette, @context, @overdub
|
|
||||||
using ReferenceTests: @test_reference
|
using ReferenceTests: @test_reference
|
||||||
|
using SimpleMock: Mock, mock
|
||||||
using Suppressor: @suppress
|
using Suppressor: @suppress
|
||||||
|
|
||||||
using PkgTemplates
|
using PkgTemplates
|
||||||
@ -20,6 +20,7 @@ Random.seed!(1)
|
|||||||
tpl(; kwargs...) = Template(; user=USER, kwargs...)
|
tpl(; kwargs...) = Template(; user=USER, kwargs...)
|
||||||
|
|
||||||
const PKG = Ref("A")
|
const PKG = Ref("A")
|
||||||
|
const CTX = gensym()
|
||||||
|
|
||||||
# Generate an unused package name.
|
# Generate an unused package name.
|
||||||
pkgname() = PKG[] *= "a"
|
pkgname() = PKG[] *= "a"
|
||||||
|
@ -54,12 +54,6 @@
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@context ErrorOnRepoInit
|
|
||||||
function Cassette.prehook(::ErrorOnRepoInit, ::typeof(LibGit2.init), pkg_dir)
|
|
||||||
@test isdir(pkg_dir)
|
|
||||||
error()
|
|
||||||
end
|
|
||||||
|
|
||||||
@testset "Package generation errors" begin
|
@testset "Package generation errors" begin
|
||||||
mktempdir() do dir
|
mktempdir() do dir
|
||||||
t = tpl(; dir=dirname(dir))
|
t = tpl(; dir=dirname(dir))
|
||||||
@ -73,6 +67,8 @@ end
|
|||||||
|
|
||||||
t = tpl()
|
t = tpl()
|
||||||
pkg = pkgname()
|
pkg = pkgname()
|
||||||
@test_throws ErrorException @overdub ErrorOnRepoInit() @suppress t(pkg)
|
mock(CTX, LibGit2.init => dir -> (@test isdir(dir); error())) do _init
|
||||||
|
@test_throws ErrorException @suppress t(pkg)
|
||||||
|
end
|
||||||
@test !isdir(joinpath(t.dir, pkg))
|
@test !isdir(joinpath(t.dir, pkg))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user