PkgTemplates.jl/test/git.jl
Chris de Graaf 5e843dadbb
Replace Cassette mocking with SimpleMock
FYI: CI should fail until SimpleMock is finished being registered.
2019-09-26 00:32:06 +07:00

52 lines
1.7 KiB
Julia

@testset "Git repositories" begin
@testset "Does not create Git repo" begin
t = tpl(; disable_defaults=[Git])
with_pkg(t) do pkg
pkg_dir = joinpath(t.dir, pkg)
@test !isdir(joinpath(pkg_dir, ".git"))
end
end
@testset "Creates Git repo" begin
t = tpl(; plugins=[Git()])
with_pkg(t) do pkg
pkg_dir = joinpath(t.dir, pkg)
@test isdir(joinpath(pkg_dir, ".git"))
end
end
@testset "With HTTPS" begin
t = tpl(; plugins=[Git(; ssh=false)])
with_pkg(t) do pkg
LibGit2.with(GitRepo(joinpath(t.dir, pkg))) do repo
remote = LibGit2.get(GitRemote, repo, "origin")
@test startswith(LibGit2.url(remote), "https://")
end
end
end
@testset "With SSH" begin
t = tpl(; plugins=[Git(; ssh=true)])
with_pkg(t) do pkg
LibGit2.with(GitRepo(joinpath(t.dir, pkg))) do repo
remote = LibGit2.get(GitRemote, repo, "origin")
@test startswith(LibGit2.url(remote), "git@")
end
end
end
@testset "Adds version to commit message" begin
# We're careful to avoid a Pkg.update as it triggers Cassette#130.
t = tpl(; disable_defaults=[Tests], plugins=[Git()])
mock(CTX, Pkg.installed => () -> Dict("PkgTemplates" => v"1.2.3")) do _pi
with_pkg(t) do pkg
pkg_dir = joinpath(t.dir, pkg)
LibGit2.with(GitRepo(pkg_dir)) do repo
commit = GitCommit(repo, "HEAD")
@test occursin("PkgTemplates version: 1.2.3", LibGit2.message(commit))
end
end
end
end
end