mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
Rationale: All of the integration tests are already covered in GitHb CI (using Kubernetes), and they tend to be a bit flaky on OpenShift.
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
package integration
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path"
|
|
"path/filepath"
|
|
"runtime"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
|
|
"github.com/redhat-developer/odo/pkg/odo/cli/plugins"
|
|
"github.com/redhat-developer/odo/tests/helper"
|
|
)
|
|
|
|
var sampleScript = []byte(`
|
|
#!/bin/sh
|
|
echo 'hello'
|
|
`)
|
|
|
|
var _ = Describe("odo plugin functionality", Label(helper.LabelSkipOnOpenShift), func() {
|
|
var tempDir string
|
|
var origPath = os.Getenv("PATH")
|
|
var handler plugins.PluginHandler
|
|
var _ = BeforeEach(func() {
|
|
var err error
|
|
tempDir, err = os.MkdirTemp(os.TempDir(), "odo")
|
|
Expect(err).NotTo(HaveOccurred())
|
|
os.Setenv("PATH", fmt.Sprintf("%s:%s", origPath, tempDir))
|
|
var baseScriptName = "tst-script"
|
|
scriptName := path.Join(tempDir, baseScriptName)
|
|
err = os.WriteFile(scriptName, sampleScript, 0755)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
handler = plugins.NewExecHandler("tst")
|
|
})
|
|
|
|
var _ = AfterEach(func() {
|
|
err := os.RemoveAll(tempDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
os.Setenv("PATH", origPath)
|
|
})
|
|
|
|
Context("when an executable with the correct prefix exists on the path", func() {
|
|
It("finds the plugin", func() {
|
|
if runtime.GOOS == "windows" {
|
|
Skip("doesn't find scripts on Windows platform")
|
|
}
|
|
found := handler.Lookup("script")
|
|
Expect(found).Should(Equal(filepath.Join(tempDir, "tst-script")))
|
|
})
|
|
})
|
|
|
|
Context("when no executable with the correct prefix exists on the path", func() {
|
|
It("does not find the plugin", func() {
|
|
if runtime.GOOS == "windows" {
|
|
Skip("doesn't find scripts on Windows platform")
|
|
}
|
|
found := handler.Lookup("unknown")
|
|
Expect(found).Should(Equal(""))
|
|
})
|
|
})
|
|
})
|