Skip to content

Commit c35648b

Browse files
committed
e2e: add e2e test for no config sync run
1 parent 0d2149e commit c35648b

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed

e2e/tests/sync/sync.go

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,66 @@ var _ = DevSpaceDescribe("sync", func() {
3737
})
3838

3939
ginkgo.It("devspace sync should work with and without config", func() {
40-
// TODO:
41-
// test devspace sync command with devspace.yaml and without devspace.yaml
40+
tempDir, err := framework.CopyToTempDir("tests/sync/testdata/no-config")
41+
framework.ExpectNoError(err)
42+
defer framework.CleanupTempDir(initialDir, tempDir)
43+
44+
ns, err := kubeClient.CreateNamespace("sync")
45+
framework.ExpectNoError(err)
46+
defer func() {
47+
err := kubeClient.DeleteNamespace(ns)
48+
framework.ExpectNoError(err)
49+
}()
50+
51+
// deploy app to sync
52+
deployCmd := &cmd.DeployCmd{
53+
GlobalFlags: &flags.GlobalFlags{
54+
NoWarn: true,
55+
Namespace: ns,
56+
ConfigPath: "sync.yaml",
57+
},
58+
}
59+
err = deployCmd.Run(f)
60+
framework.ExpectNoError(err)
61+
62+
// interrupt chan for the sync command
63+
interrupt, stop := framework.InterruptChan()
64+
defer stop()
65+
66+
// sync with watch
67+
syncCmd := &cmd.SyncCmd{
68+
GlobalFlags: &flags.GlobalFlags{
69+
NoWarn: true,
70+
Namespace: ns,
71+
},
72+
ImageSelector: "node:13.14-alpine",
73+
ContainerPath: "/app",
74+
UploadOnly: true,
75+
Polling: true,
76+
Exclude: []string{"file2.txt"},
77+
Interrupt: interrupt,
78+
}
79+
80+
// start the command
81+
waitGroup := sync.WaitGroup{}
82+
waitGroup.Add(1)
83+
go func() {
84+
defer ginkgo.GinkgoRecover()
85+
defer waitGroup.Done()
86+
87+
err := syncCmd.Run(f)
88+
framework.ExpectNoError(err)
89+
}()
90+
91+
// wait until files were synced
92+
framework.ExpectRemoteFileContents("node:13.14-alpine", ns, "/app/file1.txt", "Hello World")
93+
framework.ExpectRemoteFileNotFound("node:13.14-alpine", ns, "/app/file2.txt")
94+
95+
// stop sync
96+
stop()
97+
98+
// wait for the command to finish
99+
waitGroup.Wait()
42100
})
43101

44102
ginkgo.It("should execute a command after sync", func() {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello World
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DO NOT SYNC THIS FILE
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: v1beta11
2+
vars:
3+
- name: IMAGE
4+
value: node:13.14-alpine
5+
deployments:
6+
- name: test
7+
helm:
8+
componentChart: true
9+
values:
10+
containers:
11+
- image: ${IMAGE}
12+
command: ["sleep"]
13+
args: ["999999999999"]

0 commit comments

Comments
 (0)