kubectl/pkg/framework/test/democli/integration/integration_test.go

32 lines
997 B
Go

package integration_test
import (
"os/exec"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("DemoCLI Integration", func() {
It("can give us a helpful help message", func() {
helpfulMessage := `This is a demo kubernetes CLI, which interacts with the kubernetes API.`
command := exec.Command(pathToDemoCommand, "--help")
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(session).Should(gexec.Exit(0))
Expect(session.Out).To(gbytes.Say(helpfulMessage))
})
It("can get a list of pods", func() {
apiURL := fixtures.Config.APIServerURL
command := exec.Command(pathToDemoCommand, "listPods", "--api-url", apiURL)
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(session).Should(gexec.Exit(0))
Expect(session.Out).To(gbytes.Say("There are no pods."))
})
})