testing

package
v1.7.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChartListContent = []byte{} /* 1257 elements not displayed */

ChartListContent is the mock data of chart list

View Source
var HelmChartContent = []byte{} /* 17597 elements not displayed */

HelmChartContent is mock data of chart tgz...

View Source
var MockChartRepoHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	hlog.Infof("Incoming testing request: %s", r.RequestURI)
	switch r.RequestURI {
	case "/health":
		if r.Method == http.MethodGet {
			mockStatus := make(map[string]interface{})
			mockStatus["health"] = true
			data, _ := json.Marshal(mockStatus)
			w.Write(data)

			return
		}
	case "/repo1/index.yaml", "/library/index.yaml":
		if r.Method == http.MethodGet {
			w.Write([]byte(repo1IndexYaml))
			return
		}
	case "/repo2/index.yaml":
		if r.Method == http.MethodGet {
			w.Write([]byte(repo2IndexYaml))
			return
		}
	case "/not-existing-ns/index.yaml":
		if r.Method == http.MethodGet {
			w.WriteHeader(http.StatusNotFound)
			return
		}
	case "/repo1/charts/harbor-0.2.0.tgz",
		"/library/charts/harbor-0.2.0.tgz":
		if r.Method == http.MethodGet {
			w.Write(HelmChartContent)
			return
		}
	case "/api/repo1/charts", "/api/library/charts":
		if r.Method == http.MethodGet {
			w.Write(ChartListContent)
			return
		}
	case "/api/repo1/charts/harbor/0.2.0",
		"/api/library/charts/harbor/0.2.0":
		if r.Method == http.MethodGet {
			w.Write([]byte(harborChartV))
			return
		}
		if r.Method == http.MethodDelete {
			w.WriteHeader(http.StatusOK)
			return
		}
	case "/api/repo1/charts/harbor/1.0.0":
		if r.Method == http.MethodGet {
			w.WriteHeader(http.StatusNotFound)
			w.Write([]byte("Not found"))
			return
		}
	case "/api/repo1/charts/harbor/0.2.1",
		"/api/library/charts/harbor/0.2.1":
		if r.Method == http.MethodDelete {
			w.WriteHeader(http.StatusOK)
			return
		}
	case "/api/repo1/charts/harbor":
		if r.Method == http.MethodGet {
			w.Write([]byte(chartVersionsOfHarbor))
			return
		}
	case "/api/library/charts/harbor":
		if r.Method == http.MethodGet {
			w.Write([]byte(chartVersionsOfHarbor))
			return
		}
		if r.Method == http.MethodDelete {
			w.WriteHeader(http.StatusOK)
		}
	case "/repo3/charts/harbor-0.8.1.tgz":
		if r.Method == http.MethodGet {
			w.WriteHeader(http.StatusUnauthorized)
			w.Write([]byte("Unauthorized"))
			return
		}
	case "/api/project_for_test_deletable/charts":
		if r.Method == http.MethodGet {
			w.Write([]byte("{}"))
			return
		}
	default:
		if r.Method == http.MethodGet {
			if strings.HasSuffix(r.RequestURI, "/index.yaml") {
				w.Write([]byte(repo2IndexYaml))
				return
			}
		}
	}

	w.WriteHeader(http.StatusNotImplemented)
	w.Write([]byte("not supported"))
})

MockChartRepoHandler is the backend chart server handler

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL