-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add validation that HelmRepository is not nil when discovering throug…
…h Get Profile
- Loading branch information
nikimanoledaki
committed
Jan 31, 2022
1 parent
cd450d3
commit 728b4b8
Showing
2 changed files
with
45 additions
and
0 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 |
---|---|---|
|
@@ -134,6 +134,17 @@ var _ = Describe("Add", func() { | |
Expect(err).To(MatchError("failed to make GET request to service weave-system/wego-app path \"/v1/profiles\": nope")) | ||
}) | ||
|
||
It("fails if it's unable to discover the HelmRepository's name and namespace values", func() { | ||
gitProviders.RepositoryExistsReturns(true, nil) | ||
gitProviders.GetRepoFilesReturns(makeTestFiles(), nil) | ||
clientSet.AddProxyReactor("services", func(action testing.Action) (handled bool, ret restclient.ResponseWrapper, err error) { | ||
return true, newFakeResponseWrapper(getRespWithoutHelmRepo()), nil | ||
}) | ||
err := profilesSvc.Add(context.TODO(), gitProviders, addOptions) | ||
Expect(err).NotTo(BeNil()) | ||
Expect(err).To(MatchError("failed to discover HelmRepository's name and namespace")) | ||
}) | ||
|
||
It("fails if the config repo's filesystem could not be fetched", func() { | ||
gitProviders.RepositoryExistsReturns(true, nil) | ||
clientSet.AddProxyReactor("services", func(action testing.Action) (handled bool, ret restclient.ResponseWrapper, err error) { | ||
|
@@ -298,3 +309,34 @@ func makeTestFiles() []*gitprovider.CommitFile { | |
} | ||
return commitFiles | ||
} | ||
|
||
func getRespWithoutHelmRepo() string { | ||
return `{ | ||
"profiles": [ | ||
{ | ||
"name": "podinfo", | ||
"home": "https://github.com/stefanprodan/podinfo", | ||
"sources": [ | ||
"https://github.com/stefanprodan/podinfo" | ||
], | ||
"description": "Podinfo Helm chart for Kubernetes", | ||
"keywords": [], | ||
"maintainers": [ | ||
{ | ||
"name": "stefanprodan", | ||
"email": "[email protected]", | ||
"url": "" | ||
} | ||
], | ||
"icon": "", | ||
"annotations": {}, | ||
"kubeVersion": ">=1.19.0-0", | ||
"availableVersions": [ | ||
"6.0.0", | ||
"6.0.1" | ||
] | ||
} | ||
] | ||
} | ||
` | ||
} |