Skip to content

Commit 504b0cc

Browse files
authored
Symlink internal dir in e2e (#871)
* symlink both `pkg` and `internal` dirs to the test project's `vendor` when running e2e tests locally * some cleanup.
1 parent 4942cd8 commit 504b0cc

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

internal/util/projutil/project_util.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,21 @@ import (
2121
"path/filepath"
2222
"strings"
2323

24+
"github.com/operator-framework/operator-sdk/pkg/scaffold"
2425
"github.com/operator-framework/operator-sdk/pkg/scaffold/ansible"
2526
"github.com/operator-framework/operator-sdk/pkg/scaffold/helm"
2627

2728
log "github.com/sirupsen/logrus"
2829
"github.com/spf13/cobra"
2930
)
3031

31-
const (
32-
SrcDir = "src"
33-
mainFile = "./cmd/manager/main.go"
34-
buildDockerfile = "./build/Dockerfile"
35-
)
36-
3732
const (
3833
GopathEnv = "GOPATH"
34+
SrcDir = "src"
3935
)
4036

37+
var mainFile = filepath.Join(scaffold.ManagerDir, scaffold.CmdFile)
38+
4139
// OperatorType - the type of operator
4240
type OperatorType = string
4341

@@ -57,7 +55,7 @@ const (
5755
func MustInProjectRoot() {
5856
// if the current directory has the "./build/dockerfile" file, then it is safe to say
5957
// we are at the project root.
60-
_, err := os.Stat(buildDockerfile)
58+
_, err := os.Stat(filepath.Join(scaffold.BuildDir, scaffold.DockerfileFile))
6159
if err != nil {
6260
if os.IsNotExist(err) {
6361
log.Fatal("must run command in project root dir: project structure requires ./build/Dockerfile")

test/e2e/memcached_test.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,12 @@ func TestMemcached(t *testing.T) {
224224
}
225225
// link local sdk to vendor if not in travis
226226
if repo == "" {
227-
os.RemoveAll("vendor/github.com/operator-framework/operator-sdk/pkg")
228-
os.Symlink(filepath.Join(gopath, "src/github.com/operator-framework/operator-sdk/pkg"),
229-
"vendor/github.com/operator-framework/operator-sdk/pkg")
227+
for _, dir := range []string{"pkg", "internal"} {
228+
repoDir := filepath.Join("github.com/operator-framework/operator-sdk", dir)
229+
vendorDir := filepath.Join("vendor", repoDir)
230+
os.RemoveAll(vendorDir)
231+
os.Symlink(filepath.Join(gopath, projutil.SrcDir, repoDir), vendorDir)
232+
}
230233
}
231234

232235
file, err := yamlutil.GenerateCombinedGlobalManifest()

0 commit comments

Comments
 (0)