github.com/KusionStack/kpm@v0.8.4-0.20240326033734-dc72298a30e5/pkg/cmd/cmd_push_test.go (about) 1 // Copyright 2023 The KCL Authors. All rights reserved. 2 // Deprecated: The entire contents of this file will be deprecated. 3 // Please use the kcl cli - https://github.com/kcl-lang/cli. 4 5 package cmd 6 7 import ( 8 "os" 9 "path/filepath" 10 "testing" 11 12 "github.com/stretchr/testify/assert" 13 "kcl-lang.io/kpm/pkg/client" 14 pkg "kcl-lang.io/kpm/pkg/package" 15 ) 16 17 const testDataDir = "test_data" 18 19 func getTestDir(subDir string) string { 20 pwd, _ := os.Getwd() 21 testDir := filepath.Join(pwd, testDataDir) 22 testDir = filepath.Join(testDir, subDir) 23 24 return testDir 25 } 26 27 func TestGenDefaultOciUrlForKclPkg(t *testing.T) { 28 pkgPath := getTestDir("test_gen_oci_url") 29 kclPkg, err := pkg.LoadKclPkg(pkgPath) 30 assert.Equal(t, err, nil) 31 kpmcli, err := client.NewKpmClient() 32 assert.Equal(t, err, nil) 33 url, err := genDefaultOciUrlForKclPkg(kclPkg, kpmcli) 34 assert.Equal(t, err, nil) 35 assert.Equal(t, url, "oci://ghcr.io/kcl-lang/test_gen_oci_url") 36 }