fix: the file path checking is incorrect on windows (#475)
Co-authored-by: rick <LinuxSuRen@users.noreply.github.com>
This commit is contained in:
parent
c415efadbe
commit
dd90d1e90e
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2023 API Testing Authors.
|
||||
Copyright 2023-2024 API Testing Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -124,7 +124,7 @@ func (l *fileLoader) Put(item string) (err error) {
|
|||
defer l.lock.Unlock()
|
||||
|
||||
if l.parent == "" {
|
||||
l.parent = path.Dir(item)
|
||||
l.parent = filepath.Dir(item)
|
||||
}
|
||||
|
||||
if strings.HasPrefix(item, "http://") || strings.HasPrefix(item, "https://") {
|
||||
|
@ -144,7 +144,7 @@ func (l *fileLoader) Put(item string) (err error) {
|
|||
|
||||
// GetContext returns the context of current test case
|
||||
func (l *fileLoader) GetContext() string {
|
||||
return path.Dir(l.paths[l.index])
|
||||
return filepath.Dir(l.paths[l.index])
|
||||
}
|
||||
|
||||
// GetCount returns the count of test cases
|
||||
|
@ -207,7 +207,7 @@ func (l *fileLoader) CreateSuite(name, api string) (err error) {
|
|||
err = fmt.Errorf("suite %s already exists", name)
|
||||
} else {
|
||||
if l.parent == "" {
|
||||
l.parent = path.Dir(absPath)
|
||||
l.parent = filepath.Dir(absPath)
|
||||
}
|
||||
|
||||
if err = os.MkdirAll(l.parent, 0755); err != nil {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2023 API Testing Authors.
|
||||
Copyright 2023-2024 API Testing Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,6 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
_ "embed"
|
||||
|
@ -36,9 +35,6 @@ func TestParse(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
// make sure the sample file contains the header
|
||||
assert.True(t, strings.HasPrefix(string(data), atest.GetHeader()))
|
||||
|
||||
suite, err := atest.Parse(data)
|
||||
if assert.Nil(t, err) && assert.NotNil(t, suite) {
|
||||
assert.Equal(t, "Gitlab", suite.Name)
|
||||
|
|
Loading…
Reference in New Issue