Files
kubevela/references/plugins/capcenter_test.go
chival f4feb1af9c Add oss registry support (#1715)
* Add oss registry support

* fix test

* refactor and clean up URL parse logic

* add:design docs

* change default registry to oss
2021-06-02 18:32:54 +08:00

68 lines
1.7 KiB
Go

/*
Copyright 2021 The KubeVela Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package plugins
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseURL(t *testing.T) {
cases := map[string]struct {
url string
exp *GithubContent
expType string
}{
"api-github": {
url: "https://api.github.com/repos/zzxwill/catalog/contents/repository?ref=plugin",
expType: TypeGithub,
exp: &GithubContent{
Owner: "zzxwill",
Repo: "catalog",
Path: "repository",
Ref: "plugin",
},
},
"github-copy-path": {
url: "https://github.com/zzxwill/catalog/tree/plugin/repository",
expType: TypeGithub,
exp: &GithubContent{
Owner: "zzxwill",
Repo: "catalog",
Path: "repository",
Ref: "plugin",
},
},
"github-manuel-write-path": {
url: "https://github.com/zzxwill/catalog/repository",
expType: TypeGithub,
exp: &GithubContent{
Owner: "zzxwill",
Repo: "catalog",
Path: "repository",
},
},
}
for caseName, c := range cases {
tp, content, err := Parse(c.url)
assert.NoError(t, err, caseName)
assert.Equal(t, c.exp, &content.GithubContent, caseName)
assert.Equal(t, c.expType, tp, caseName)
}
}