Skip to content

Commit

Permalink
Fix import_test google regex
Browse files Browse the repository at this point in the history
Signed-off-by: Tiger Kaovilai <[email protected]>
  • Loading branch information
kaovilai committed Sep 11, 2024
1 parent 1457428 commit 3b50436
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 4 additions & 6 deletions pkg/install/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
)

// test that this framework do not import cloud provider
// test that this package do not import cloud provider

// Prevent https://github.com/vmware-tanzu/velero/issues/8207 and https://github.com/vmware-tanzu/velero/issues/8157
func TestPkgImportNoCloudProvider(t *testing.T) {
Expand All @@ -20,8 +20,8 @@ func TestPkgImportNoCloudProvider(t *testing.T) {
t.Fatalf("No caller information")
}
t.Logf("Current test file path: %s", filename)
t.Logf("Current test directory: %s", filepath.Dir(filename)) // should be "pkg/install"
// go list -f {{.Deps}} ./pkg/install/
t.Logf("Current test directory: %s", filepath.Dir(filename)) // should be this package name
// go list -f {{.Deps}} ./<path-to-this-package-dir>
cmd := exec.Command(
"go",
"list",
Expand All @@ -39,13 +39,11 @@ func TestPkgImportNoCloudProvider(t *testing.T) {
// ignore k8s.io
k8sio, err := regexp.Compile("^k8s.io")
require.NoError(t, err)
cloudProvider, err := regexp.Compile("aws|gcp|azure")
cloudProvider, err := regexp.Compile("aws|cloud.google.com|azure")
require.NoError(t, err)
// depsArr :=[]string{}
cloudProviderDeps := []string{}
for _, dep := range strings.Split(deps, "\n") {
if !k8sio.MatchString(dep) {
// depsArr = append(depsArr, dep)
if cloudProvider.MatchString(dep) {
cloudProviderDeps = append(cloudProviderDeps, dep)
}
Expand Down
10 changes: 4 additions & 6 deletions pkg/plugin/framework/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
)

// test that this framework do not import cloud provider
// test that this package do not import cloud provider

// Prevent https://github.com/vmware-tanzu/velero/issues/8207 and https://github.com/vmware-tanzu/velero/issues/8157
func TestPkgImportNoCloudProvider(t *testing.T) {
Expand All @@ -20,8 +20,8 @@ func TestPkgImportNoCloudProvider(t *testing.T) {
t.Fatalf("No caller information")
}
t.Logf("Current test file path: %s", filename)
t.Logf("Current test directory: %s", filepath.Dir(filename)) // should be "pkg/install"
// go list -f {{.Deps}} ./pkg/install/
t.Logf("Current test directory: %s", filepath.Dir(filename)) // should be this package name
// go list -f {{.Deps}} ./<path-to-this-package-dir>
cmd := exec.Command(
"go",
"list",
Expand All @@ -39,13 +39,11 @@ func TestPkgImportNoCloudProvider(t *testing.T) {
// ignore k8s.io
k8sio, err := regexp.Compile("^k8s.io")
require.NoError(t, err)
cloudProvider, err := regexp.Compile("aws|gcp|azure")
cloudProvider, err := regexp.Compile("aws|cloud.google.com|azure")
require.NoError(t, err)
// depsArr :=[]string{}
cloudProviderDeps := []string{}
for _, dep := range strings.Split(deps, "\n") {
if !k8sio.MatchString(dep) {
// depsArr = append(depsArr, dep)
if cloudProvider.MatchString(dep) {
cloudProviderDeps = append(cloudProviderDeps, dep)
}
Expand Down

0 comments on commit 3b50436

Please sign in to comment.