Skip to content

Commit

Permalink
Integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Aug 11, 2022
1 parent 21798ac commit 128ada9
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/examples/source/devfiles/nodejs/devfile-child.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
schemaVersion: 2.1.0
metadata:
name: child
parent:
uri: devfile-parent.yaml
61 changes: 61 additions & 0 deletions tests/examples/source/devfiles/nodejs/devfile-parent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
commands:
- exec:
commandLine: npm install
component: runtime
group:
isDefault: true
kind: build
workingDir: /project
id: install
- exec:
commandLine: npm start
component: runtime
group:
isDefault: true
kind: run
workingDir: /project
id: run
- exec:
commandLine: npm run debug
component: runtime
group:
isDefault: true
kind: debug
workingDir: /project
id: debug
- exec:
commandLine: npm test
component: runtime
group:
isDefault: true
kind: test
workingDir: /project
id: test
components:
- container:
endpoints:
- name: http-3000
targetPort: 3000
image: registry.access.redhat.com/ubi8/nodejs-14:latest
memoryLimit: 1024Mi
mountSources: true
sourceMapping: /project
name: runtime
metadata:
description: Stack with Node.js 14
displayName: Node.js Runtime
icon: https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg
language: javascript
name: nodejs-prj1-api-abhz
projectType: nodejs
tags:
- NodeJS
- Express
- ubi8
version: 1.0.1
schemaVersion: 2.0.0
starterProjects:
- git:
remotes:
origin: https://github.com/odo-devfiles/nodejs-ex.git
name: nodejs-starter
12 changes: 12 additions & 0 deletions tests/helper/helper_filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,15 @@ func CreateSimpleFile(context, filePrefix, fileExtension string) (string, string

return FilePath, string(content)
}

func AppendToFile(filepath string, s string) error {
f, err := os.OpenFile(filepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return err
}
defer f.Close()
if _, err := f.WriteString(s); err != nil {
return err
}
return nil
}
36 changes: 36 additions & 0 deletions tests/integration/cmd_dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2215,4 +2215,40 @@ CMD ["npm", "start"]
})
})
})

When("a devfile with a local parent is used for odo dev and the parent is not synced", func() {
var devSession helper.DevSession
BeforeEach(func() {
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-child.yaml"), filepath.Join(commonVar.Context, "devfile.yaml"))
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-parent.yaml"), filepath.Join(commonVar.Context, "devfile-parent.yaml"))
helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context)
var err error
devSession, _, _, _, err = helper.StartDevMode(nil)
Expect(err).ToNot(HaveOccurred())

gitignorePath := filepath.Join(commonVar.Context, ".gitignore")
err = helper.AppendToFile(gitignorePath, "\n/devfile-parent.yaml\n")
Expect(err).ToNot(HaveOccurred())
})

AfterEach(func() {
// We stop the process so the process does not remain after the end of the tests
devSession.Kill()
devSession.WaitEnd()
})

When("updating the parent", func() {
BeforeEach(func() {
helper.ReplaceString("devfile-parent.yaml", "1024Mi", "1023Mi")
})

It("should update the component", func() {
Eventually(func() string {
stdout, _, _, err := devSession.GetInfo()
Expect(err).ToNot(HaveOccurred())
return string(stdout)
}, 180, 10).Should(ContainSubstring("Updating Component"))
})
})
})
})

0 comments on commit 128ada9

Please sign in to comment.