mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-02 23:23:45 +01:00
24c0be789d
- 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>
30 lines
587 B
Go
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)
|