Skip to content

Commit d53e7ff

Browse files
committed
chore: replace deprecated routine filepath.HasPrefix with strings.HasPrefix
1 parent 33dabbd commit d53e7ff

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

pkg/jobs/common_job_list_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"log"
77
"path/filepath"
8+
"strings"
89
"testing"
910
"time"
1011

@@ -111,7 +112,7 @@ func TestCommonJobList_SelectedJobsProduceFiles(t *testing.T) {
111112
if len(content) == 0 {
112113
t.Fatalf("job %s file %s has empty content", job.Name, path)
113114
}
114-
if !filepath.HasPrefix(path, dc.BaseDir) { // acceptable here; test code (Go <1.22 deprecation not critical)
115+
if !strings.HasPrefix(filepath.ToSlash(path), filepath.ToSlash(dc.BaseDir)) {
115116
t.Fatalf("job %s file path %s does not start with basedir %s", job.Name, path, dc.BaseDir)
116117
}
117118
}

pkg/jobs/nic_job_list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestNICJobList_CRDObjects(t *testing.T) {
110110
t.Errorf("CRD job returned error: %v", result.Error)
111111
}
112112
for file, content := range result.Files {
113-
if !filepath.HasPrefix(file, tmpDir) {
113+
if !strings.HasPrefix(filepath.ToSlash(file), filepath.ToSlash(tmpDir)) {
114114
t.Errorf("File path %s does not start with tmpDir", file)
115115
}
116116
var out map[string]interface{}

0 commit comments

Comments
 (0)