|
| 1 | +package imports |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/loft-sh/devspace/cmd" |
| 5 | + "github.com/loft-sh/devspace/cmd/flags" |
| 6 | + "github.com/loft-sh/devspace/e2e/framework" |
| 7 | + "github.com/loft-sh/devspace/e2e/kube" |
| 8 | + "github.com/loft-sh/devspace/pkg/util/factory" |
| 9 | + "github.com/onsi/ginkgo" |
| 10 | + "os" |
| 11 | +) |
| 12 | + |
| 13 | +var _ = DevSpaceDescribe("imports", func() { |
| 14 | + initialDir, err := os.Getwd() |
| 15 | + if err != nil { |
| 16 | + panic(err) |
| 17 | + } |
| 18 | + |
| 19 | + // create a new factory |
| 20 | + var ( |
| 21 | + f factory.Factory |
| 22 | + kubeClient *kube.KubeHelper |
| 23 | + ) |
| 24 | + |
| 25 | + ginkgo.BeforeEach(func() { |
| 26 | + f = framework.NewDefaultFactory() |
| 27 | + |
| 28 | + kubeClient, err = kube.NewKubeHelper() |
| 29 | + framework.ExpectNoError(err) |
| 30 | + }) |
| 31 | + |
| 32 | + ginkgo.FIt("should import correctly", func() { |
| 33 | + tempDir, err := framework.CopyToTempDir("tests/imports/testdata/local") |
| 34 | + framework.ExpectNoError(err) |
| 35 | + defer framework.CleanupTempDir(initialDir, tempDir) |
| 36 | + |
| 37 | + ns, err := kubeClient.CreateNamespace("imports") |
| 38 | + framework.ExpectNoError(err) |
| 39 | + defer func() { |
| 40 | + err := kubeClient.DeleteNamespace(ns) |
| 41 | + framework.ExpectNoError(err) |
| 42 | + }() |
| 43 | + |
| 44 | + // create a new dev command |
| 45 | + deployCmd := &cmd.DeployCmd{ |
| 46 | + GlobalFlags: &flags.GlobalFlags{ |
| 47 | + NoWarn: true, |
| 48 | + Namespace: ns, |
| 49 | + }, |
| 50 | + } |
| 51 | + |
| 52 | + // run the command |
| 53 | + err = deployCmd.Run(f) |
| 54 | + framework.ExpectNoError(err) |
| 55 | + framework.ExpectLocalFileContentsWithoutSpaces("dependency.txt", "import3") |
| 56 | + framework.ExpectLocalFileContentsWithoutSpaces("import1.txt", "import1") |
| 57 | + framework.ExpectLocalFileContentsWithoutSpaces("import2.txt", "import2") |
| 58 | + framework.ExpectLocalFileContentsWithoutSpaces("import3.txt", "import3") |
| 59 | + framework.ExpectLocalFileContentsWithoutSpaces("vars.txt", ns+"-"+ns+"-base-import1-import2-import3") |
| 60 | + }) |
| 61 | +}) |
0 commit comments