harbor/src/chartserver/base_test.go
Steven Zou 24c0be789d Add more UT cases for changed chart API
- add more cases in the ChartRepositoryAPI controller
- move chart utility testing functions to a separate go file under testing
- ignore testing coverage for testing folder
- update other UT cases to reflect the change of adding chart testing utility functions

Signed-off-by: Steven Zou <szou@vmware.com>
2018-09-20 17:51:27 +08:00

30 lines
587 B
Go

package chartserver
import (
"net/http/httptest"
"net/url"
"github.com/goharbor/harbor/src/testing"
)
// createMockObjects create mock objects for chart repo related testing.
func createMockObjects() (*httptest.Server, *Controller, error) {
s := httptest.NewServer(testing.MockChartRepoHandler)
backendURL, err := url.Parse(s.URL)
if err != nil {
s.Close()
return nil, nil, err
}
mockController, err := NewController(backendURL)
if err != nil {
s.Close()
return nil, nil, err
}
return s, mockController, nil
}
// Http client
var httpClient = NewChartClient(nil)