github.com/oam-dev/kubevela@v1.9.11/pkg/utils/helm/repo_index_test.go (about) 1 /* 2 Copyright 2023 The KubeVela Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 package helm 17 18 import ( 19 "context" 20 "fmt" 21 "strings" 22 "testing" 23 ) 24 25 func TestLoadRepo(t *testing.T) { 26 27 u := "https://charts.kubevela.net/core" 28 29 ctx := context.Background() 30 index, err := LoadRepoIndex(ctx, u, &RepoCredential{}) 31 if err != nil { 32 t.Errorf("load repo failed, err: %s", err) 33 t.Failed() 34 return 35 } 36 37 for _, entry := range index.Entries { 38 chartUrl := entry[0].URLs[0] 39 40 if !(strings.HasPrefix(chartUrl, "https://") || strings.HasPrefix(chartUrl, "http://")) { 41 chartUrl = fmt.Sprintf("%s/%s", u, chartUrl) 42 } 43 chartData, err := loadData(chartUrl, &RepoCredential{}) 44 if err != nil { 45 t.Errorf("load chart data failed, err: %s", err) 46 t.Failed() 47 } 48 _ = chartData 49 break 50 } 51 52 }