-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d45bf4
commit 6ffc6ae
Showing
7 changed files
with
148 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package getter | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestGCSDetector(t *testing.T) { | ||
cases := []struct { | ||
Input string | ||
Output string | ||
}{ | ||
{ | ||
"www.googleapis.com/storage/v1/bucket/foo", | ||
"gcs::https://www.googleapis.com/storage/v1/bucket/foo", | ||
}, | ||
{ | ||
"www.googleapis.com/storage/v1/bucket/foo/bar", | ||
"gcs::https://www.googleapis.com/storage/v1/bucket/foo/bar", | ||
}, | ||
{ | ||
"www.googleapis.com/storage/v1/foo/bar.baz", | ||
"gcs::https://www.googleapis.com/storage/v1/foo/bar.baz", | ||
}, | ||
} | ||
|
||
pwd := "/pwd" | ||
f := new(GCSDetector) | ||
for i, tc := range cases { | ||
output, ok, err := f.Detect(tc.Input, pwd) | ||
if err != nil { | ||
t.Fatalf("err: %s", err) | ||
} | ||
if !ok { | ||
t.Fatal("not ok") | ||
} | ||
|
||
if output != tc.Output { | ||
t.Fatalf("%d: bad: %#v", i, output) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package getter | ||
|
||
import ( | ||
"encoding/base64" | ||
"io/ioutil" | ||
"net/url" | ||
"os" | ||
|
@@ -227,32 +228,32 @@ func TestGitGetter_gitVersion(t *testing.T) { | |
} | ||
} | ||
|
||
// func TestGitGetter_sshKey(t *testing.T) { | ||
// if !testHasGit { | ||
// t.Log("git not found, skipping") | ||
// t.Skip() | ||
// } | ||
func TestGitGetter_sshKey(t *testing.T) { | ||
if !testHasGit { | ||
t.Log("git not found, skipping") | ||
t.Skip() | ||
} | ||
|
||
// g := new(GitGetter) | ||
// dst := tempDir(t) | ||
g := new(GitGetter) | ||
dst := tempDir(t) | ||
|
||
// encodedKey := base64.StdEncoding.EncodeToString([]byte(testGitToken)) | ||
encodedKey := base64.StdEncoding.EncodeToString([]byte(testGitToken)) | ||
|
||
// u, err := url.Parse("ssh://[email protected]/hashicorp/test-private-repo" + | ||
// "?sshkey=" + encodedKey) | ||
// if err != nil { | ||
// t.Fatal(err) | ||
// } | ||
u, err := url.Parse("ssh://[email protected]/hashicorp/test-private-repo" + | ||
"?sshkey=" + encodedKey) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// if err := g.Get(dst, u); err != nil { | ||
// t.Fatalf("err: %s", err) | ||
// } | ||
if err := g.Get(dst, u); err != nil { | ||
t.Fatalf("err: %s", err) | ||
} | ||
|
||
// readmePath := filepath.Join(dst, "README.md") | ||
// if _, err := os.Stat(readmePath); err != nil { | ||
// t.Fatalf("err: %s", err) | ||
// } | ||
// } | ||
readmePath := filepath.Join(dst, "README.md") | ||
if _, err := os.Stat(readmePath); err != nil { | ||
t.Fatalf("err: %s", err) | ||
} | ||
} | ||
|
||
func TestGitGetter_submodule(t *testing.T) { | ||
if !testHasGit { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": 3, | ||
"serial": 1, | ||
"lineage": "cace175f-2333-0ab6-3108-ace60b611a78", | ||
"modules": [ | ||
{ | ||
"path": [ | ||
"root" | ||
], | ||
"outputs": {}, | ||
"resources": {}, | ||
"depends_on": [] | ||
} | ||
] | ||
} |