Commit 4573939f authored by jackgr's avatar jackgr

Update expander test repo provider

parent c391fc17
...@@ -35,12 +35,16 @@ import ( ...@@ -35,12 +35,16 @@ import (
) )
var ( var (
TestRepoBucket = "kubernetes-charts-testing" TestRepoBucket = "kubernetes-charts-testing"
TestRepoURL = "gs://" + TestRepoBucket TestRepoURL = "gs://" + TestRepoBucket
TestChartName = "frobnitz" TestChartName = "frobnitz"
TestChartVersion = "0.0.1" TestChartVersion = "0.0.1"
TestArchiveName = TestChartName + "-" + TestChartVersion + ".tgz" TestArchiveName = TestChartName + "-" + TestChartVersion + ".tgz"
TestResourceType = TestRepoURL + "/" + TestArchiveName TestResourceType = TestRepoURL + "/" + TestArchiveName
TestRepoType = string(repo.GCSRepoType)
TestRepoFormat = string(repo.GCSRepoFormat)
TestRepoCredentialName = "default"
TestRepoName = TestRepoBucket
) )
var validResponseTestCaseData = []byte(` var validResponseTestCaseData = []byte(`
...@@ -262,7 +266,7 @@ func TestExpandTemplate(t *testing.T) { ...@@ -262,7 +266,7 @@ func TestExpandTemplate(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(etc.Handler)) ts := httptest.NewServer(http.HandlerFunc(etc.Handler))
defer ts.Close() defer ts.Close()
expander := NewExpander(ts.URL, nil) expander := NewExpander(ts.URL, getTestRepoProvider(t))
resource := &common.Resource{ resource := &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: TestResourceType, Type: TestResourceType,
...@@ -368,3 +372,18 @@ func expanderSuccessHandler(w http.ResponseWriter, r *http.Request) { ...@@ -368,3 +372,18 @@ func expanderSuccessHandler(w http.ResponseWriter, r *http.Request) {
svcResp := getValidServiceResponse() svcResp := getValidServiceResponse()
util.LogHandlerExitWithJSON(handler, w, svcResp, http.StatusOK) util.LogHandlerExitWithJSON(handler, w, svcResp, http.StatusOK)
} }
func getTestRepoProvider(t *testing.T) repo.IRepoProvider {
rs := repo.NewInmemRepoService()
rp := repo.NewRepoProvider(rs, nil, nil)
tr, err := repo.NewRepo(TestRepoURL, TestRepoCredentialName, TestRepoName, TestRepoFormat, TestRepoType)
if err != nil {
t.Fatalf("cannot create test repository: %s", err)
}
if err := rs.CreateRepo(tr); err != nil {
t.Fatalf("cannot initialize repository service: %s", err)
}
return rp
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment