-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed_test.go
46 lines (40 loc) · 1.23 KB
/
seed_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 main
import (
"testing"
)
func TestRepoFromString(t *testing.T) {
githubTestOwner := "mikemilano"
githubTestProject := "seeder"
ownerSlashProject := githubTestOwner + "/" + githubTestProject
// Test with GithubPath
inputUrl := githubTestOwner + "/" + githubTestProject
inputPath := "foo"
expectedUrl := "ssh://git@github.com/" + ownerSlashProject
repo, err := NewSeed(inputUrl)
if err != nil {
t.Error(err)
}
if repo == (Seed{}) {
t.Error("Expected repo, got empty struct")
}
if repo.path != "" {
t.Error("Expected empty path, got ", repo.path)
}
if repo.url.String() != expectedUrl {
t.Error("Expected url to resolve to ssh://git@github.com/"+inputUrl+", got ", repo.url.String())
}
// Test with Path and clone URL format
inputUrl = "git@github.com:" + githubTestOwner + "/" + githubTestProject + ".git"
inputPath = "foo"
expectedUrl = "ssh://git@github.com/" + ownerSlashProject + ".git"
repo, err = NewSeed(inputUrl, inputPath)
if err != nil {
t.Error(err)
}
if repo.path != inputPath {
t.Error("Expected path: "+inputPath+", got ", repo.path)
}
if repo.url.String() != expectedUrl {
t.Error("Expected url to resolve to ssh://git@github.com/"+ownerSlashProject+".git, got ", repo.url.String())
}
}