github.com/confluentinc/cli@v1.100.0/test/utils.go (about)

     1  package test
     2  
     3  import (
     4  	"io/ioutil"
     5  	"path/filepath"
     6  	"runtime"
     7  	"testing"
     8  )
     9  
    10  func LoadFixture(t *testing.T, fixture string) string {
    11  	content, err := ioutil.ReadFile(FixturePath(t, fixture))
    12  	if err != nil {
    13  		t.Fatal(err)
    14  	}
    15  	return string(content)
    16  }
    17  
    18  func FixturePath(t *testing.T, fixture string) string {
    19  	_, filename, _, ok := runtime.Caller(0)
    20  	if !ok {
    21  		t.Fatalf("problems recovering caller information")
    22  	}
    23  
    24  	return filepath.Join(filepath.Dir(filename), "fixtures", "output", fixture)
    25  }