Skip to content
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: 10 additions & 0 deletions e2e/framework/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package framework

import (
"context"
"os"

"github.com/onsi/ginkgo/v2"
)
Expand Down Expand Up @@ -35,6 +36,15 @@ func CopyTestdata(testdataPath, initialDir string) string {
return tempDir
}

// CopyTestdataNoChdir copies testdataPath to a temp dir and removes it on cleanup.
func CopyTestdataNoChdir(testdataPath string) string {
tempDir, err := CopyToTempDirWithoutChdir(testdataPath)
ExpectNoErrorWithOffset(1, err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })

return tempDir
}

// SetupDockerWorkspaceAndUp is SetupDockerWorkspace followed by devsy up.
func SetupDockerWorkspaceAndUp(
ctx context.Context,
Expand Down
58 changes: 10 additions & 48 deletions e2e/tests/configread/configread.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ var _ = ginkgo.Describe("config read command", ginkgo.Label("config-read"), func

ginkgo.It("outputs valid JSON with expected fields", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/configread/testdata",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/configread/testdata")

stdout, _, err := f.ExecCommandCapture(ctx, []string{
cmdConfig, cmdRead,
Expand Down Expand Up @@ -70,11 +66,7 @@ var _ = ginkgo.Describe("config read command", ginkgo.Label("config-read"), func

ginkgo.It("includes features with --include-features-configuration", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/configread/testdata",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/configread/testdata")

stdout, _, err := f.ExecCommandCapture(ctx, []string{
cmdConfig, cmdRead,
Expand All @@ -98,11 +90,7 @@ var _ = ginkgo.Describe("config read command", ginkgo.Label("config-read"), func
ginkgo.It("includes merged configuration with --include-merged-configuration",
func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/configread/testdata",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/configread/testdata")

stdout, _, err := f.ExecCommandCapture(ctx, []string{
cmdConfig, cmdRead,
Expand Down Expand Up @@ -148,11 +136,7 @@ var _ = ginkgo.Describe("config read command", ginkgo.Label("config-read"), func
ginkgo.It("expands forwardPorts range syntax in merged configuration",
func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/configread/testdata-port-range",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/configread/testdata-port-range")

stdout, _, err := f.ExecCommandCapture(ctx, []string{
cmdConfig, cmdRead,
Expand Down Expand Up @@ -190,11 +174,7 @@ var _ = ginkgo.Describe("config read command", ginkgo.Label("config-read"), func
ginkgo.It("preserves otherPortsAttributes in merged configuration",
func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/configread/testdata-port-attributes",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/configread/testdata-port-attributes")

stdout, _, err := f.ExecCommandCapture(ctx, []string{
cmdConfig, cmdRead,
Expand Down Expand Up @@ -230,11 +210,7 @@ var _ = ginkgo.Describe("config read command", ginkgo.Label("config-read"), func

ginkgo.It("preserves containerEnv in configuration output", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/configread/testdata-container-env",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/configread/testdata-container-env")

stdout, _, err := f.ExecCommandCapture(ctx, []string{
cmdConfig, cmdRead,
Expand All @@ -257,11 +233,7 @@ var _ = ginkgo.Describe("config read command", ginkgo.Label("config-read"), func

ginkgo.It("preserves containerEnv in merged configuration", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/configread/testdata-container-env",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/configread/testdata-container-env")

stdout, _, err := f.ExecCommandCapture(ctx, []string{
cmdConfig, cmdRead,
Expand All @@ -285,11 +257,7 @@ var _ = ginkgo.Describe("config read command", ginkgo.Label("config-read"), func

ginkgo.It("preserves hostRequirements in configuration output", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/configread/testdata-host-requirements",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/configread/testdata-host-requirements")

stdout, _, err := f.ExecCommandCapture(ctx, []string{
cmdConfig, cmdRead,
Expand All @@ -313,11 +281,7 @@ var _ = ginkgo.Describe("config read command", ginkgo.Label("config-read"), func

ginkgo.It("should read configuration using custom id-label",
func(ctx context.Context) {
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/configread/testdata-id-label",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/configread/testdata-id-label")

f, err := framework.SetupDockerProvider(initialDir+"/bin", "docker")
framework.ExpectNoError(err)
Expand Down Expand Up @@ -484,9 +448,7 @@ var _ = ginkgo.Describe("config read command", ginkgo.Label("config-read"), func
ginkgo.Label("config-read"),
func(ctx context.Context, testdataDir, expected string) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(testdataDir)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir(testdataDir)

stdout, _, err := f.ExecCommandCapture(ctx, []string{
cmdConfig, cmdRead,
Expand Down
66 changes: 14 additions & 52 deletions e2e/tests/extends/extends.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ var _ = ginkgo.Describe("extends property", ginkgo.Label("extends"), func() {

ginkgo.It("resolves single-level extends inheriting parent fields", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/extends/testdata/single-level",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/extends/testdata/single-level")

stdout, _, err := readConfiguration(ctx, f, tempDir)
framework.ExpectNoError(err)
Expand All @@ -54,11 +50,7 @@ var _ = ginkgo.Describe("extends property", ginkgo.Label("extends"), func() {

ginkgo.It("deep merges map fields from parent and child", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/extends/testdata/deep-merge",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/extends/testdata/deep-merge")

stdout, _, err := readConfiguration(ctx, f, tempDir)
framework.ExpectNoError(err)
Expand All @@ -80,11 +72,7 @@ var _ = ginkgo.Describe("extends property", ginkgo.Label("extends"), func() {

ginkgo.It("replaces array fields entirely from child", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/extends/testdata/array-replace",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/extends/testdata/array-replace")

stdout, _, err := readConfiguration(ctx, f, tempDir)
framework.ExpectNoError(err)
Expand All @@ -108,11 +96,7 @@ var _ = ginkgo.Describe("extends property", ginkgo.Label("extends"), func() {

ginkgo.It("resolves multi-level extends chain", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/extends/testdata/multi-level",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/extends/testdata/multi-level")

stdout, _, err := readConfiguration(ctx, f, tempDir)
framework.ExpectNoError(err)
Expand All @@ -133,23 +117,15 @@ var _ = ginkgo.Describe("extends property", ginkgo.Label("extends"), func() {

ginkgo.It("returns error on circular extends", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/extends/testdata/cycle",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/extends/testdata/cycle")

_, _, err = readConfiguration(ctx, f, tempDir)
_, _, err := readConfiguration(ctx, f, tempDir)
framework.ExpectError(err)
}, ginkgo.SpecTimeout(framework.TimeoutShort()))

ginkgo.It("resolves array extends with multiple parents", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/extends/testdata/array-extends",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/extends/testdata/array-extends")

stdout, _, err := readConfiguration(ctx, f, tempDir)
framework.ExpectNoError(err)
Expand All @@ -173,13 +149,9 @@ var _ = ginkgo.Describe("extends property", ginkgo.Label("extends"), func() {

ginkgo.It("returns error when extends references missing file", func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/extends/testdata/missing-file",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/extends/testdata/missing-file")

_, _, err = readConfiguration(ctx, f, tempDir)
_, _, err := readConfiguration(ctx, f, tempDir)
framework.ExpectError(err)
}, ginkgo.SpecTimeout(framework.TimeoutShort()))

Expand Down Expand Up @@ -306,11 +278,7 @@ var _ = ginkgo.Describe("extends property", ginkgo.Label("extends"), func() {
ginkgo.Label("extends"),
func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
"tests/extends/testdata/varsub-localenv",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })
tempDir := framework.CopyTestdataNoChdir("tests/extends/testdata/varsub-localenv")

gomega.Expect(os.Setenv("TEST_EXTENDS_DIR", tempDir)).To(gomega.Succeed())
ginkgo.DeferCleanup(func() {
Expand Down Expand Up @@ -344,11 +312,9 @@ var _ = ginkgo.Describe("extends property", ginkgo.Label("extends"), func() {
ginkgo.Label("extends"),
func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
tempDir := framework.CopyTestdataNoChdir(
"tests/extends/testdata/varsub-workspace-folder",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })

stdout, _, err := readConfiguration(ctx, f, tempDir)
framework.ExpectNoError(err)
Expand Down Expand Up @@ -377,11 +343,9 @@ var _ = ginkgo.Describe("extends property", ginkgo.Label("extends"), func() {
ginkgo.Label("extends"),
func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
tempDir := framework.CopyTestdataNoChdir(
"tests/extends/testdata/varsub-localenv-default",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })

gomega.Expect(os.Unsetenv("DEVSY_UNSET_VAR")).To(gomega.Succeed())

Expand Down Expand Up @@ -412,15 +376,13 @@ var _ = ginkgo.Describe("extends property", ginkgo.Label("extends"), func() {
ginkgo.Label("extends"),
func(ctx context.Context) {
f := framework.NewDefaultFramework(initialDir + "/bin")
tempDir, err := framework.CopyToTempDirWithoutChdir(
tempDir := framework.CopyTestdataNoChdir(
"tests/extends/testdata/varsub-localenv-missing",
)
framework.ExpectNoError(err)
ginkgo.DeferCleanup(func() { _ = os.RemoveAll(tempDir) })

gomega.Expect(os.Unsetenv("DEVSY_NONEXISTENT_VAR")).To(gomega.Succeed())

_, _, err = readConfiguration(ctx, f, tempDir)
_, _, err := readConfiguration(ctx, f, tempDir)
framework.ExpectError(err)
}, ginkgo.SpecTimeout(framework.TimeoutShort()))
})
Expand Down
Loading