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

Do not depend on GOPATH to locate test data #122

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much, but what do you think about moving the test yaml to this folder?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not need to part of this change, we can file a bug and handle it as a follow up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I prefer that in a separated PR because it is not really part of this fix.

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