1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-09-05 11:06:23 -07:00

Fix PanicIfNotTest and GoToGochanRoot

This commit is contained in:
Eggbertx 2024-12-23 09:19:05 -08:00
parent 2b0a6a9d54
commit 64e1e6e15a

View file

@ -3,7 +3,7 @@ package testutil
import (
"errors"
"os"
"path"
"path/filepath"
"strings"
"testing"
)
@ -14,7 +14,7 @@ const (
// PanicIfNotTest panics if the function was called directly or indirectly by a test function via go test
func PanicIfNotTest() {
if !strings.HasSuffix(os.Args[0], ".test") && os.Args[1] != "-test.run" {
if !strings.HasSuffix(os.Args[0], ".test") && !strings.HasSuffix(os.Args[0], ".test.exe") && os.Args[1] != "-test.run" {
panic("the testutil package should only be used in tests")
}
}
@ -30,7 +30,7 @@ func GoToGochanRoot(t *testing.T) (string, error) {
if err != nil {
return "", err
}
if path.Base(dir) == "gochan" {
if filepath.Base(dir) == "gochan" {
return dir, nil
}
if err = os.Chdir(".."); err != nil {