-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite remoteload_test integration tests (#4783)
* Better error message when git clone fails * support file:// URLs * rewrite remoteload_test * lint and test fix * fixes for kverey's comments * document file:// remote load * replace assert with require where appropriate * add tests for file:// without git suffix * fixes plus pr review from natasha * fixes for review, lint * revert changes to error handling * fix skipped test
- Loading branch information
1 parent
d6e40a3
commit e62480d
Showing
16 changed files
with
633 additions
and
450 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
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNewRepoSpecFromUrl_Permute(t *testing.T) { | ||
|
@@ -61,6 +62,7 @@ func TestNewRepoSpecFromUrl_Permute(t *testing.T) { | |
rs, err := NewRepoSpecFromURL(uri) | ||
if err != nil { | ||
t.Errorf("problem %v", err) | ||
continue | ||
} | ||
if rs.Host != hostSpec { | ||
bad = append(bad, []string{"host", uri, rs.Host, hostSpec}) | ||
|
@@ -120,6 +122,7 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) { | |
repoSpec RepoSpec | ||
cloneSpec string | ||
absPath string | ||
skip string | ||
}{ | ||
{ | ||
name: "t1", | ||
|
@@ -285,11 +288,134 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) { | |
GitSuffix: ".git", | ||
}, | ||
}, | ||
{ | ||
name: "t15", | ||
input: "https://github.com/kubernetes-sigs/kustomize//examples/multibases/dev/?ref=v1.0.6", | ||
cloneSpec: "https://github.com/kubernetes-sigs/kustomize.git", | ||
absPath: notCloned.Join("/examples/multibases/dev"), | ||
repoSpec: RepoSpec{ | ||
Host: "https://github.com/", | ||
OrgRepo: "kubernetes-sigs/kustomize", | ||
Path: "/examples/multibases/dev/", | ||
Ref: "v1.0.6", | ||
GitSuffix: ".git", | ||
}, | ||
}, | ||
{ | ||
name: "t16", | ||
input: "file://a/b/c/someRepo.git/somepath?ref=someBranch", | ||
cloneSpec: "file://a/b/c/someRepo.git", | ||
absPath: notCloned.Join("somepath"), | ||
repoSpec: RepoSpec{ | ||
Host: "file://", | ||
OrgRepo: "a/b/c/someRepo", | ||
Path: "somepath", | ||
Ref: "someBranch", | ||
GitSuffix: ".git", | ||
}, | ||
}, | ||
{ | ||
name: "t17", | ||
input: "file://a/b/c/someRepo//somepath?ref=someBranch", | ||
cloneSpec: "file://a/b/c/someRepo", | ||
absPath: notCloned.Join("somepath"), | ||
repoSpec: RepoSpec{ | ||
Host: "file://", | ||
OrgRepo: "a/b/c/someRepo", | ||
Path: "somepath", | ||
Ref: "someBranch", | ||
}, | ||
}, | ||
{ | ||
name: "t18", | ||
input: "file://a/b/c/someRepo?ref=someBranch", | ||
cloneSpec: "file://a/b/c/someRepo", | ||
absPath: notCloned.String(), | ||
repoSpec: RepoSpec{ | ||
Host: "file://", | ||
OrgRepo: "a/b/c/someRepo", | ||
Ref: "someBranch", | ||
}, | ||
}, | ||
{ | ||
name: "t19", | ||
input: "file:///a/b/c/someRepo?ref=someBranch", | ||
cloneSpec: "file:///a/b/c/someRepo", | ||
absPath: notCloned.String(), | ||
repoSpec: RepoSpec{ | ||
Host: "file://", | ||
OrgRepo: "/a/b/c/someRepo", | ||
Ref: "someBranch", | ||
}, | ||
}, | ||
{ | ||
name: "t20", | ||
input: "ssh://[email protected]/kubernetes-sigs/kustomize//examples/multibases/dev?ref=v1.0.6", | ||
cloneSpec: "[email protected]:kubernetes-sigs/kustomize.git", | ||
absPath: notCloned.Join("examples/multibases/dev"), | ||
repoSpec: RepoSpec{ | ||
Host: "[email protected]:", | ||
OrgRepo: "kubernetes-sigs/kustomize", | ||
Path: "/examples/multibases/dev", | ||
Ref: "v1.0.6", | ||
GitSuffix: ".git", | ||
}, | ||
}, | ||
{ | ||
name: "t21", | ||
input: "file:///a/b/c/someRepo", | ||
cloneSpec: "file:///a/b/c/someRepo", | ||
absPath: notCloned.String(), | ||
repoSpec: RepoSpec{ | ||
Host: "file://", | ||
OrgRepo: "/a/b/c/someRepo", | ||
}, | ||
}, | ||
{ | ||
name: "t22", | ||
input: "file:///", | ||
cloneSpec: "file:///", | ||
absPath: notCloned.String(), | ||
repoSpec: RepoSpec{ | ||
Host: "file://", | ||
OrgRepo: "/", | ||
}, | ||
}, | ||
{ | ||
name: "t23", | ||
skip: "the `//` repo separator does not work", | ||
input: "https://fake-git-hosting.org/path/to/repo//examples/multibases/dev", | ||
cloneSpec: "https://fake-git-hosting.org/path/to.git", | ||
absPath: notCloned.Join("/examples/multibases/dev"), | ||
repoSpec: RepoSpec{ | ||
Host: "https://fake-git-hosting.org/", | ||
OrgRepo: "path/to/repo", | ||
Path: "/examples/multibases/dev", | ||
GitSuffix: ".git", | ||
}, | ||
}, | ||
{ | ||
name: "t24", | ||
skip: "the `//` repo separator does not work", | ||
input: "ssh://[email protected]/path/to/repo//examples/multibases/dev", | ||
cloneSpec: "ssh://[email protected]/path/to/repo.git", | ||
absPath: notCloned.Join("/examples/multibases/dev"), | ||
repoSpec: RepoSpec{ | ||
Host: "ssh://[email protected]", | ||
OrgRepo: "path/to/repo", | ||
Path: "/examples/multibases/dev", | ||
GitSuffix: ".git", | ||
}, | ||
}, | ||
} | ||
for _, tc := range testcases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
if tc.skip != "" { | ||
t.Skip(tc.skip) | ||
} | ||
|
||
rs, err := NewRepoSpecFromURL(tc.input) | ||
assert.NoError(t, err) | ||
require.NoError(t, err) | ||
assert.Equal(t, tc.cloneSpec, rs.CloneSpec(), "cloneSpec mismatch") | ||
assert.Equal(t, tc.absPath, rs.AbsPath(), "absPath mismatch") | ||
// some values have defaults. Clear them here so test cases remain compact. | ||
|
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
Oops, something went wrong.