github.com/Benchkram/bob@v0.0.0-20220321080157-7c8f3876e225/test/setup/cachesetup/cachesetup.go (about)

     1  package cachesetup
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  
     7  	"github.com/Benchkram/bob/bob/global"
     8  )
     9  
    10  // Setup creates cache directory structure to be used in a test setup.
    11  func Setup(dir string) (cache string, artifact string, buildInfo string, err error) {
    12  	cache = filepath.Join(dir, global.BobCacheDir)
    13  	err = os.MkdirAll(cache, 0700)
    14  	if err != nil {
    15  		return "", "", "", err
    16  	}
    17  	artifact = filepath.Join(dir, global.BobCacheArtifactsDir)
    18  	err = os.MkdirAll(artifact, 0700)
    19  	if err != nil {
    20  		return "", "", "", err
    21  	}
    22  
    23  	buildInfo = filepath.Join(dir, global.BobCacheBuildinfoDir)
    24  	err = os.MkdirAll(buildInfo, 0700)
    25  	if err != nil {
    26  		return "", "", "", err
    27  	}
    28  	return cache, artifact, buildInfo, nil
    29  }