Files
odo/tests/integration/interactive/cmd_init_test.go
Anand Kumar Singh 3eb92b6a47 POC for odo interactive testing (#5466)
* POC for odo interactive testing

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* add interactive tests to make target test-integration

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* [WIP] use func to pass test instructions

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* cleanup comments/test

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* cleanup minor changes

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* fix unit test failure

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* skip for windows

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* skip for windows by not compiling, cleanup

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* cleanup, and add the make target to test files

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* incorporate review, adding comments, cleanup

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* fix failing make validate

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* update test dependency, and possible fix for windows

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* Revert "update test dependency, and possible fix for windows"

This reverts commit 55580b7dc5.

* Final cleanup

Signed-off-by: anandrkskd <anandrkskd@gmail.com>
2022-03-02 13:50:26 -05:00

63 lines
1.7 KiB
Go

//go:build linux || darwin || dragonfly || solaris || openbsd || netbsd || freebsd
// +build linux darwin dragonfly solaris openbsd netbsd freebsd
package interactive
import (
"bytes"
"fmt"
"github.com/Netflix/go-expect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/redhat-developer/odo/tests/helper"
)
var _ = Describe("odo init interactive command tests", func() {
var commonVar helper.CommonVar
// This is run before every Spec (It)
var _ = BeforeEach(func() {
commonVar = helper.CommonBeforeEach()
helper.Chdir(commonVar.Context)
})
// Clean up after the test
// This is run after every Spec (It)
var _ = AfterEach(func() {
helper.CommonAfterEach(commonVar)
})
It("should download correct devfile", func() {
command := []string{"odo", "init"}
output, err := helper.RunInteractive(command, func(c *expect.Console, output *bytes.Buffer) {
res := helper.ExpectString(c, "Select language")
fmt.Fprintln(output, res)
helper.SendLine(c, "go")
res = helper.ExpectString(c, "Select project type")
fmt.Fprintln(output, res)
helper.SendLine(c, "\n")
res = helper.ExpectString(c, "Which starter project do you want to use")
fmt.Fprintln(output, res)
helper.SendLine(c, "\n")
res = helper.ExpectString(c, "Enter component name")
fmt.Fprintln(output, res)
helper.SendLine(c, "my-go-app")
res = helper.ExpectString(c, "Your new component \"my-go-app\" is ready in the current directory.")
fmt.Fprintln(output, res)
})
Expect(err).To(BeNil())
Expect(output).To(ContainSubstring("Your new component \"my-go-app\" is ready in the current directory."))
Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElements("devfile.yaml"))
})
})