-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
Copy pathsourceref_test.go
40 lines (36 loc) · 1.02 KB
/
sourceref_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
package app
import (
"testing"
"github.com/openshift/origin/pkg/generate/app/test"
)
func TestFromGitURL(t *testing.T) {
gen := &SourceRefGenerator{&test.FakeGit{}}
srcRef, err := gen.FromGitURL("[email protected]:openshift/origin.git#test_branch", "")
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if srcRef.Ref != "test_branch" {
t.Errorf("Unexpected branch: %s", srcRef.Ref)
}
if srcRef.URL.String() != "[email protected]:openshift/origin.git" {
t.Errorf("Unexpected URL: %s", srcRef.URL.String())
}
}
func TestFromDirectory(t *testing.T) {
git := &test.FakeGit{
RootDir: "/tmp/test",
GitURL: "https://github.com/openshift/test-project",
Ref: "stable",
}
gen := &SourceRefGenerator{git}
srcRef, err := gen.FromDirectory("/test/dir")
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if srcRef.Ref != "stable" {
t.Errorf("Unexpected branch: %s", srcRef.Ref)
}
if srcRef.URL.String() != "https://github.com/openshift/test-project" {
t.Errorf("Unexpected URL: %s", srcRef.URL.String())
}
}