Skip to content

Commit dd90d1e

Browse files
authored
fix: the file path checking is incorrect on windows (#475)
Co-authored-by: rick <[email protected]>
1 parent c415efa commit dd90d1e

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

pkg/testing/loader_file.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 API Testing Authors.
2+
Copyright 2023-2024 API Testing Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -124,7 +124,7 @@ func (l *fileLoader) Put(item string) (err error) {
124124
defer l.lock.Unlock()
125125

126126
if l.parent == "" {
127-
l.parent = path.Dir(item)
127+
l.parent = filepath.Dir(item)
128128
}
129129

130130
if strings.HasPrefix(item, "http://") || strings.HasPrefix(item, "https://") {
@@ -144,7 +144,7 @@ func (l *fileLoader) Put(item string) (err error) {
144144

145145
// GetContext returns the context of current test case
146146
func (l *fileLoader) GetContext() string {
147-
return path.Dir(l.paths[l.index])
147+
return filepath.Dir(l.paths[l.index])
148148
}
149149

150150
// GetCount returns the count of test cases
@@ -207,7 +207,7 @@ func (l *fileLoader) CreateSuite(name, api string) (err error) {
207207
err = fmt.Errorf("suite %s already exists", name)
208208
} else {
209209
if l.parent == "" {
210-
l.parent = path.Dir(absPath)
210+
l.parent = filepath.Dir(absPath)
211211
}
212212

213213
if err = os.MkdirAll(l.parent, 0755); err != nil {

pkg/testing/parser_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 API Testing Authors.
2+
Copyright 2023-2024 API Testing Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@ import (
2020
"io"
2121
"net/http"
2222
"os"
23-
"strings"
2423
"testing"
2524

2625
_ "embed"
@@ -36,9 +35,6 @@ func TestParse(t *testing.T) {
3635
return
3736
}
3837

39-
// make sure the sample file contains the header
40-
assert.True(t, strings.HasPrefix(string(data), atest.GetHeader()))
41-
4238
suite, err := atest.Parse(data)
4339
if assert.Nil(t, err) && assert.NotNil(t, suite) {
4440
assert.Equal(t, "Gitlab", suite.Name)

0 commit comments

Comments
 (0)