github.com/kick-project/maker@v1.1.1-0.20211031110251-7b74922fa493/internal/resources/testtools/testtools.go (about)

     1  package testtools
     2  
     3  import (
     4  	"path"
     5  	"path/filepath"
     6  	"runtime"
     7  )
     8  
     9  // FixtureDir returns the path to the fixture directory.
    10  func FixtureDir() (fixturedir string) {
    11  	_, filename, _, ok := runtime.Caller(0)
    12  	if !ok {
    13  		panic("Can not get filename")
    14  	}
    15  	fixturedir, err := filepath.Abs(path.Join(path.Dir(filename), "..", "..", "..", "fixtures"))
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  	return fixturedir
    20  }
    21  
    22  // TempDir returns the path to the localized tmp/ directory.
    23  func TempDir() (tempdir string) {
    24  	_, filename, _, ok := runtime.Caller(0)
    25  	if !ok {
    26  		panic("Can not get filename")
    27  	}
    28  	tempdir, err := filepath.Abs(path.Join(path.Dir(filename), "..", "..", "..", "tmp"))
    29  	if err != nil {
    30  		panic(err)
    31  	}
    32  	return tempdir
    33  }