Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Do not depend on GOPATH to locate test data (#122)
Browse files Browse the repository at this point in the history
GOPATH is not mandatory to have now and the source code may not be
stored under GOPATH.
  • Loading branch information
honnix authored Sep 3, 2020
1 parent ff64ab8 commit 48c93d6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
10 changes: 4 additions & 6 deletions pkg/executioncluster/impl/random_cluster_selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package impl

import (
"context"
"go/build"
"os"
"path/filepath"
"strings"
"testing"

"github.com/golang/protobuf/proto"
Expand All @@ -32,13 +30,13 @@ const testDomain = "domain"
const testWorkflow = "name"

func initTestConfig(fileName string) error {
var searchPaths []string
for _, goPath := range strings.Split(build.Default.GOPATH, string(os.PathListSeparator)) {
searchPaths = append(searchPaths, filepath.Join(goPath, "src/github.com/lyft/flyteadmin/pkg/executioncluster/testdata/", fileName))
pwd, err := os.Getwd()
if err != nil {
return err
}

configAccessor := viper.NewAccessor(config.Options{
SearchPaths: searchPaths,
SearchPaths: []string{filepath.Join(pwd, "../testdata", fileName)},
StrictMode: false,
})
return configAccessor.UpdateConfig(context.Background())
Expand Down
10 changes: 4 additions & 6 deletions pkg/runtime/cluster_resource_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package runtime

import (
"context"
"go/build"
"os"
"strings"
"testing"

"path/filepath"
Expand All @@ -15,13 +13,13 @@ import (
)

func initTestClusterResourceConfig() error {
var searchPaths []string
for _, goPath := range strings.Split(build.Default.GOPATH, string(os.PathListSeparator)) {
searchPaths = append(searchPaths, filepath.Join(goPath, "src/github.com/lyft/flyteadmin/pkg/runtime/testdata/cluster_resource_config.yaml"))
pwd, err := os.Getwd()
if err != nil {
return err
}

configAccessor := viper.NewAccessor(config.Options{
SearchPaths: searchPaths,
SearchPaths: []string{filepath.Join(pwd, "testdata/cluster_resource_config.yaml")},
StrictMode: false,
})
return configAccessor.UpdateConfig(context.TODO())
Expand Down
10 changes: 4 additions & 6 deletions pkg/runtime/config_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package runtime

import (
"context"
"go/build"
"os"
"strings"
"testing"

"path/filepath"
Expand All @@ -15,13 +13,13 @@ import (
)

func initTestConfig() error {
var searchPaths []string
for _, goPath := range strings.Split(build.Default.GOPATH, string(os.PathListSeparator)) {
searchPaths = append(searchPaths, filepath.Join(goPath, "src/github.com/lyft/flyteadmin/pkg/runtime/testdata/clusters_config.yaml"))
pwd, err := os.Getwd()
if err != nil {
return err
}

configAccessor := viper.NewAccessor(config.Options{
SearchPaths: searchPaths,
SearchPaths: []string{filepath.Join(pwd, "testdata/clusters_config.yaml")},
StrictMode: false,
})
return configAccessor.UpdateConfig(context.TODO())
Expand Down

0 comments on commit 48c93d6

Please sign in to comment.