forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibgit2-online.jl
38 lines (34 loc) · 1.2 KB
/
libgit2-online.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This file is a part of Julia. License is MIT: http://julialang.org/license
@testset "libgit2-online" begin
#########
# TESTS #
#########
# init & clone
mktempdir() do dir
repo_url = "https://github.com/JuliaLang/Example.jl"
@testset "Cloning repository" begin
@testset "with 'https' protocol" begin
repo_path = joinpath(dir, "Example1")
repo = LibGit2.clone(repo_url, repo_path)
try
@test isdir(repo_path)
@test isdir(joinpath(repo_path, ".git"))
finally
close(repo)
end
end
@testset "with incorrect url" begin
try
repo_path = joinpath(dir, "Example2")
# credentials are required because github tries to authenticate on unknown repo
cred = LibGit2.UserPasswordCredentials("","") # empty credentials cause authentication error
LibGit2.clone(repo_url*randstring(10), repo_path, payload=Nullable(cred))
error("unexpected")
catch ex
@test isa(ex, LibGit2.Error.GitError)
@test ex.code == LibGit2.Error.EAUTH
end
end
end
end
end