-
Notifications
You must be signed in to change notification settings - Fork 3
/
endpoint_test.go
46 lines (35 loc) · 1.16 KB
/
endpoint_test.go
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
39
40
41
42
43
44
45
46
package grit
import (
"testing"
"github.com/go-git/go-git/v5/plumbing/transport"
)
func TestReplaceSlug_GitUrl(t *testing.T) {
ep, err := transport.NewEndpoint("git@github.com:owner-a/repo-a.git")
if err != nil {
t.Fatal(err)
}
replaced := ReplaceSlug(ep, "owner-b/repo-b")
if replaced.String() != "ssh://git@github.com/owner-b/repo-b.git" {
t.Errorf("expected ssh://git@github.com/owner-b/repo-b.git, got %s", replaced.String())
}
}
func TestReplaceSlug_SshUrl(t *testing.T) {
ep, err := transport.NewEndpoint("ssh://git@github.com/owner-a/repo-a.git")
if err != nil {
t.Fatal(err)
}
replaced := ReplaceSlug(ep, "owner-b/repo-b")
if replaced.String() != "ssh://git@github.com/owner-b/repo-b.git" {
t.Errorf("expected ssh://git@github.com/owner-b/repo-b.git, got %s", replaced.String())
}
}
func TestReplaceSlug_HttpUrl(t *testing.T) {
ep, err := transport.NewEndpoint("https://github.com/owner-a/repo-a.git")
if err != nil {
t.Fatal(err)
}
replaced := ReplaceSlug(ep, "owner-b/repo-b")
if replaced.String() != "https://github.com/owner-b/repo-b.git" {
t.Errorf("expected https://github.com/owner-b/repo-b.git, got %s", replaced.String())
}
}