Skip to content

Commit

Permalink
Integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Apr 28, 2022
1 parent ba4ac95 commit fce2b60
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/integration/devfile/cmd_dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package devfile
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -1412,4 +1413,50 @@ var _ = Describe("odo dev command tests", func() {
}
})
})

When("a component with multiple endpoints is run", func() {
stateFile := ".odo/state.json"
var devSession helper.DevSession
BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project-with-multiple-endpoints"), commonVar.Context)
helper.Cmd("odo", "project", "set", commonVar.Project).ShouldPass()
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-multiple-endpoints.yaml")).ShouldPass()
Expect(helper.VerifyFileExists(".odo/state.json")).To(BeFalse())
var err error
devSession, _, _, _, err = helper.StartDevMode()
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()
})

It("should create a state file containing forwarded ports", func() {
Expect(helper.VerifyFileExists(stateFile)).To(BeTrue())
contentJSON, err := ioutil.ReadFile(stateFile)
Expect(err).ToNot(HaveOccurred())
helper.JsonPathContentIs(string(contentJSON), "forwardedPorts.0.containerName", "runtime")
helper.JsonPathContentIs(string(contentJSON), "forwardedPorts.1.containerName", "runtime")
helper.JsonPathContentIs(string(contentJSON), "forwardedPorts.0.localAddress", "127.0.0.1")
helper.JsonPathContentIs(string(contentJSON), "forwardedPorts.1.localAddress", "127.0.0.1")
helper.JsonPathContentIs(string(contentJSON), "forwardedPorts.0.containerPort", "3000")
helper.JsonPathContentIs(string(contentJSON), "forwardedPorts.1.containerPort", "4567")
})

When("odo dev is stopped", func() {
BeforeEach(func() {
devSession.Stop()
devSession.WaitEnd()
})

It("should remove forwarded ports from state file", func() {
Expect(helper.VerifyFileExists(stateFile)).To(BeTrue())
contentJSON, err := ioutil.ReadFile(stateFile)
Expect(err).ToNot(HaveOccurred())
helper.JsonPathContentIs(string(contentJSON), "forwardedPorts", "")
})
})
})
})

0 comments on commit fce2b60

Please sign in to comment.