Merge pull request #8843 from heww/fix-chart-builder

fix(chart,quota): fix path regexp of chart creation and deletion
This commit is contained in:
Wenkai Yin(尹文开) 2019-09-02 15:59:18 +08:00 committed by GitHub
commit d762e0730a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 2 deletions

View File

@ -29,8 +29,8 @@ import (
)
var (
deleteChartVersionRe = regexp.MustCompile(`^/api/chartrepo/(?P<namespace>\w+)/charts/(?P<name>\w+)/(?P<version>[\w\d\.]+)/?$`)
createChartVersionRe = regexp.MustCompile(`^/api/chartrepo/(?P<namespace>\w+)/charts/?$`)
deleteChartVersionRe = regexp.MustCompile(`^/api/chartrepo/(?P<namespace>[^?#]+)/charts/(?P<name>[^?#]+)/(?P<version>[^?#]+)/?$`)
createChartVersionRe = regexp.MustCompile(`^/api/chartrepo/(?P<namespace>[^?#]+)/charts/?$`)
)
var (

View File

@ -120,6 +120,21 @@ func (suite *HandlerSuite) TestUpload() {
uploadChartVersion(projectID, projectName, "harbor", "0.2.0")
suite.AssertResourceUsage(1, types.ResourceCount, projectID)
}, "repo1")
suite.WithProject(func(projectID int64, projectName string) {
uploadChartVersion(projectID, projectName, "harbor-ha", "dev")
suite.AssertResourceUsage(1, types.ResourceCount, projectID)
}, "harbor-contrib")
suite.WithProject(func(projectID int64, projectName string) {
uploadChartVersion(projectID, projectName, "acs-engine-autoscaler", "1.0.0")
suite.AssertResourceUsage(1, types.ResourceCount, projectID)
}, "cluster-autoscaler")
suite.WithProject(func(projectID int64, projectName string) {
uploadChartVersion(projectID, projectName, "123456", "1-0")
suite.AssertResourceUsage(1, types.ResourceCount, projectID)
}, "123456")
}
func (suite *HandlerSuite) TestDelete() {
@ -130,6 +145,30 @@ func (suite *HandlerSuite) TestDelete() {
deleteChartVersion(projectName, "harbor", "0.2.1")
suite.AssertResourceUsage(0, types.ResourceCount, projectID)
}, "repo1")
suite.WithProject(func(projectID int64, projectName string) {
uploadChartVersion(projectID, projectName, "harbor-ha", "dev")
suite.AssertResourceUsage(1, types.ResourceCount, projectID)
deleteChartVersion(projectName, "harbor-ha", "dev")
suite.AssertResourceUsage(0, types.ResourceCount, projectID)
}, "harbor-contrib")
suite.WithProject(func(projectID int64, projectName string) {
uploadChartVersion(projectID, projectName, "acs-engine-autoscaler", "1.0.0")
suite.AssertResourceUsage(1, types.ResourceCount, projectID)
deleteChartVersion(projectName, "acs-engine-autoscaler", "1.0.0")
suite.AssertResourceUsage(0, types.ResourceCount, projectID)
}, "cluster-autoscaler")
suite.WithProject(func(projectID int64, projectName string) {
uploadChartVersion(projectID, projectName, "123456", "1-0")
suite.AssertResourceUsage(1, types.ResourceCount, projectID)
deleteChartVersion(projectName, "123456", "1-0")
suite.AssertResourceUsage(0, types.ResourceCount, projectID)
}, "123456")
}
func TestRunHandlerSuite(t *testing.T) {