github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/services/integrationtesting/consistencytestutil/configs.go (about)

     1  package consistencytestutil
     2  
     3  import (
     4  	"os"
     5  	"path"
     6  	"path/filepath"
     7  	"runtime"
     8  	"strings"
     9  )
    10  
    11  const testconfigsDirectory = "testconfigs"
    12  
    13  // ListTestConfigs returns a list of all test configuration files defined in the testconfigs
    14  // directory. Must be invoked from a test defined in the integrationtesting folder.
    15  func ListTestConfigs() ([]string, error) {
    16  	_, filename, _, _ := runtime.Caller(1) // 1 for the parent caller.
    17  	consistencyTestFiles := []string{}
    18  	err := filepath.Walk(path.Join(path.Dir(filename), testconfigsDirectory), func(path string, info os.FileInfo, err error) error {
    19  		if info == nil || info.IsDir() {
    20  			return nil
    21  		}
    22  
    23  		if strings.HasSuffix(info.Name(), ".yaml") {
    24  			consistencyTestFiles = append(consistencyTestFiles, path)
    25  		}
    26  
    27  		return nil
    28  	})
    29  
    30  	return consistencyTestFiles, err
    31  }