|
|
@ -55,6 +55,20 @@ func NewTempServerWithCleanup(t *testing.T, glob string) (*Server, error) {
|
|
|
|
return srv, err
|
|
|
|
return srv, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Setup mutliple fake repos
|
|
|
|
|
|
|
|
func NewTempServerWithCleanupAndMultipleRepos(t *testing.T, glob string, repoUrls []string) (*Server, error) {
|
|
|
|
|
|
|
|
srv, err := NewTempServer(glob)
|
|
|
|
|
|
|
|
srv.Stop()
|
|
|
|
|
|
|
|
// Add the testing repository as the only repo.
|
|
|
|
|
|
|
|
if err := setTestingRepositories(repoUrls, filepath.Join(srv.docroot, "repositories.yaml")); err != nil {
|
|
|
|
|
|
|
|
panic(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
srv.CopyCharts()
|
|
|
|
|
|
|
|
srv.Start()
|
|
|
|
|
|
|
|
t.Cleanup(func() { os.RemoveAll(srv.docroot) })
|
|
|
|
|
|
|
|
return srv, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Set up a fake repo with basic auth enabled
|
|
|
|
// Set up a fake repo with basic auth enabled
|
|
|
|
func NewTempServerWithCleanupAndBasicAuth(t *testing.T, glob string) *Server {
|
|
|
|
func NewTempServerWithCleanupAndBasicAuth(t *testing.T, glob string) *Server {
|
|
|
|
srv, err := NewTempServerWithCleanup(t, glob)
|
|
|
|
srv, err := NewTempServerWithCleanup(t, glob)
|
|
|
@ -400,6 +414,7 @@ func (s *Server) Stop() {
|
|
|
|
// URL returns the URL of the server.
|
|
|
|
// URL returns the URL of the server.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Example:
|
|
|
|
// Example:
|
|
|
|
|
|
|
|
//
|
|
|
|
// http://localhost:1776
|
|
|
|
// http://localhost:1776
|
|
|
|
func (s *Server) URL() string {
|
|
|
|
func (s *Server) URL() string {
|
|
|
|
return s.srv.URL
|
|
|
|
return s.srv.URL
|
|
|
@ -423,3 +438,15 @@ func setTestingRepository(url, fname string) error {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return r.WriteFile(fname, 0644)
|
|
|
|
return r.WriteFile(fname, 0644)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// setTestingRepository sets up a testing repository.yaml with the given URLs.
|
|
|
|
|
|
|
|
func setTestingRepositories(urls []string, fname string) error {
|
|
|
|
|
|
|
|
r := repo.NewFile()
|
|
|
|
|
|
|
|
for _, url := range urls {
|
|
|
|
|
|
|
|
r.Add(&repo.Entry{
|
|
|
|
|
|
|
|
Name: "test",
|
|
|
|
|
|
|
|
URL: url,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return r.WriteFile(fname, 0644)
|
|
|
|
|
|
|
|
}
|
|
|
|