Last active
April 11, 2024 19:19
-
-
Save dexterp/d866ac2839807b525b7e0a386fecd325 to your computer and use it in GitHub Desktop.
GO testtools.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package testtools | |
import ( | |
"path" | |
"path/filepath" | |
"runtime" | |
) | |
// FixtureDir returns the path to the fixture directory. | |
func FixtureDir() (fixturedir string) { | |
_, filename, _, ok := runtime.Caller(0) | |
if !ok { | |
panic("Can not get filename") | |
} | |
fixturedir, err := filepath.Abs(path.Join(path.Dir(filename), "..", "..", "..", "fixtures")) | |
if err != nil { | |
panic(err) | |
} | |
return fixturedir | |
} | |
// TempDir returns the path to the localized tmp/ directory. | |
func TempDir() (tempdir string) { | |
_, filename, _, ok := runtime.Caller(0) | |
if !ok { | |
panic("Can not get filename") | |
} | |
tempdir, err := filepath.Abs(path.Join(path.Dir(filename), "..", "..", "..", "tmp")) | |
if err != nil { | |
panic(err) | |
} | |
return tempdir | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment