Skip to content

Commit 52cb725

Browse files
committed
fix: update tests for v6
1 parent b90c546 commit 52cb725

File tree

20 files changed

+2052
-2016
lines changed

20 files changed

+2052
-2016
lines changed

cmd/deploy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"context"
55
"fmt"
6+
67
"github.com/loft-sh/devspace/cmd/flags"
78
"github.com/loft-sh/devspace/pkg/devspace/analyze"
89
"github.com/loft-sh/devspace/pkg/devspace/build"

cmd/dev.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package cmd
22

33
import (
44
"context"
5+
"io"
6+
"os"
7+
58
"github.com/loft-sh/devspace/pkg/devspace/build"
69
"github.com/loft-sh/devspace/pkg/devspace/config"
710
"github.com/loft-sh/devspace/pkg/devspace/config/localcache"
@@ -12,8 +15,6 @@ import (
1215
"github.com/loft-sh/devspace/pkg/devspace/pipeline/types"
1316
"github.com/loft-sh/devspace/pkg/util/interrupt"
1417
"github.com/loft-sh/devspace/pkg/util/survey"
15-
"io"
16-
"os"
1718

1819
"github.com/loft-sh/devspace/pkg/devspace/plugin"
1920
"github.com/loft-sh/devspace/pkg/devspace/upgrade"

e2e/framework/util.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package framework
22

33
import (
4+
"context"
45
"fmt"
56
"io/ioutil"
67
"os"
@@ -9,8 +10,10 @@ import (
910

1011
"github.com/loft-sh/devspace/pkg/devspace/config"
1112
"github.com/loft-sh/devspace/pkg/devspace/config/loader"
13+
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
1214
"github.com/loft-sh/devspace/pkg/devspace/dependency"
1315
"github.com/loft-sh/devspace/pkg/devspace/dependency/types"
16+
"github.com/loft-sh/devspace/pkg/devspace/kubectl"
1417
"github.com/loft-sh/devspace/pkg/util/factory"
1518
"github.com/loft-sh/devspace/pkg/util/message"
1619
"github.com/onsi/ginkgo"
@@ -27,7 +30,7 @@ func BeforeAll(body func()) {
2730
})
2831
}
2932

30-
func LoadConfigWithOptionsAndResolve(f factory.Factory, configPath string, configOptions *loader.ConfigOptions, resolveOptions dependency.ResolveOptions) (config.Config, []types.Dependency, error) {
33+
func LoadConfigWithOptionsAndResolve(f factory.Factory, client kubectl.Client, configPath string, configOptions *loader.ConfigOptions, resolveOptions dependency.ResolveOptions) (config.Config, []types.Dependency, error) {
3134
before, err := os.Getwd()
3235
if err != nil {
3336
return nil, nil, err
@@ -36,7 +39,10 @@ func LoadConfigWithOptionsAndResolve(f factory.Factory, configPath string, confi
3639

3740
// Set config root
3841
log := f.GetLog()
39-
configLoader := f.NewConfigLoader(configPath)
42+
configLoader, err := f.NewConfigLoader(configPath)
43+
if err != nil {
44+
return nil, nil, err
45+
}
4046
configExists, err := configLoader.SetDevSpaceRoot(log)
4147
if err != nil {
4248
return nil, nil, err
@@ -45,26 +51,29 @@ func LoadConfigWithOptionsAndResolve(f factory.Factory, configPath string, confi
4551
}
4652

4753
// load config
48-
loadedConfig, err := configLoader.Load(configOptions, log)
54+
loadedConfig, err := configLoader.Load(context.Background(), client, configOptions, log)
4955
if err != nil {
5056
return nil, nil, err
5157
}
5258

59+
// set devspacecontext
60+
ctx := devspacecontext.NewContext(context.Background(), log).WithConfig(loadedConfig)
61+
5362
// resolve dependencies
54-
dependencies, err := dependency.NewManager(loadedConfig, nil, configOptions, log).ResolveAll(resolveOptions)
63+
dependencies, err := dependency.NewManager(ctx, configOptions).ResolveAll(ctx, resolveOptions)
5564
if err != nil {
5665
return nil, nil, fmt.Errorf("error resolving dependencies: %v", err)
5766
}
5867

5968
return loadedConfig, dependencies, nil
6069
}
6170

62-
func LoadConfigWithOptions(f factory.Factory, configPath string, configOptions *loader.ConfigOptions) (config.Config, []types.Dependency, error) {
63-
return LoadConfigWithOptionsAndResolve(f, configPath, configOptions, dependency.ResolveOptions{})
71+
func LoadConfigWithOptions(f factory.Factory, client kubectl.Client, configPath string, configOptions *loader.ConfigOptions) (config.Config, []types.Dependency, error) {
72+
return LoadConfigWithOptionsAndResolve(f, client, configPath, configOptions, dependency.ResolveOptions{})
6473
}
6574

66-
func LoadConfig(f factory.Factory, configPath string) (config.Config, []types.Dependency, error) {
67-
return LoadConfigWithOptions(f, configPath, &loader.ConfigOptions{})
75+
func LoadConfig(f factory.Factory, client kubectl.Client, configPath string) (config.Config, []types.Dependency, error) {
76+
return LoadConfigWithOptions(f, client, configPath, &loader.ConfigOptions{})
6877
}
6978

7079
func InterruptChan() (chan error, func()) {

e2e/kube/kube.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ func (k *KubeHelper) ExecByImageSelector(imageSelector, namespace string, comman
4444
WithTimeout(120).
4545
WithWaitingStrategy(targetselector.NewUntilNewestRunningWaitingStrategy(time.Second * 2))
4646

47-
container, err := targetselector.GlobalTargetSelector.SelectSingleContainer(context.TODO(), k.client, targetOptions, log.Discard)
47+
globalTargetSelector := targetselector.NewTargetSelector(targetOptions)
48+
container, err := globalTargetSelector.SelectSingleContainer(context.TODO(), k.client, log.Discard)
4849
if err != nil {
4950
return "", err
5051
}
5152

52-
stdout, stderr, err := k.client.ExecBuffered(container.Pod, container.Container.Name, command, nil)
53+
stdout, stderr, err := k.client.ExecBuffered(context.TODO(), container.Pod, container.Container.Name, command, nil)
5354
if err != nil {
5455
return "", fmt.Errorf("exec error: %v %s", err, string(stderr))
5556
}
@@ -62,12 +63,13 @@ func (k *KubeHelper) ExecByContainer(labelSelector, containerName, namespace str
6263
WithTimeout(120).
6364
WithWaitingStrategy(targetselector.NewUntilNewestRunningWaitingStrategy(time.Second * 2))
6465

65-
container, err := targetselector.GlobalTargetSelector.SelectSingleContainer(context.TODO(), k.client, targetOptions, log.Discard)
66+
globalTargetSelector := targetselector.NewTargetSelector(targetOptions)
67+
container, err := globalTargetSelector.SelectSingleContainer(context.TODO(), k.client, log.Discard)
6668
if err != nil {
6769
return "", err
6870
}
6971

70-
stdout, stderr, err := k.client.ExecBuffered(container.Pod, container.Container.Name, command, nil)
72+
stdout, stderr, err := k.client.ExecBuffered(context.TODO(), container.Pod, container.Container.Name, command, nil)
7173
if err != nil {
7274
return "", fmt.Errorf("exec error: %v %s", err, string(stderr))
7375
}

e2e/tests/build/build.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ var _ = DevSpaceDescribe("build", func() {
4040
ginkgo.BeforeEach(func() {
4141
f = framework.NewDefaultFactory()
4242
})
43-
4443
// Test cases:
45-
4644
ginkgo.It("should build dockerfile with docker", func() {
4745
tempDir, err := framework.CopyToTempDir("tests/build/testdata/docker")
4846
framework.ExpectNoError(err)
@@ -153,7 +151,9 @@ var _ = DevSpaceDescribe("build", func() {
153151
framework.ExpectNoError(err)
154152

155153
for _, image := range imageList {
156-
if image.RepoTags[0] == "my-docker-username/helloworld-custom-build:latest" {
154+
fmt.Println("+++++++++++++++++++++++++")
155+
fmt.Println(image)
156+
if len(image.RepoTags) > 0 && image.RepoTags[0] == "my-docker-username/helloworld-custom-build:latest" {
157157
err = nil
158158
break
159159
} else {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
FROM alpine
2+
COPY . .
23
CMD ["/bin/echo", "'Hello world!'"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
FROM alpine
2+
COPY . .
23
CMD ["/bin/echo", "'Hello world!'"]

e2e/tests/command/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var _ = DevSpaceDescribe("command", func() {
4141
// TODO
4242
})
4343

44-
ginkgo.It("should and shouldnt append args", func() {
44+
ginkgo.It("should and shouldn't append args", func() {
4545
tempDir, err := framework.CopyToTempDir("tests/command/testdata/command-appended-args")
4646
framework.ExpectNoError(err)
4747
defer framework.CleanupTempDir(initialDir, tempDir)

0 commit comments

Comments
 (0)