plugin_create_test.go 818 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
package cmd

import (
	"github.com/jenkins-zh/jenkins-cli/util"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"io/ioutil"
	"os"
)

var _ = Describe("plugin create test", func() {
	var (
		err error
	)

	BeforeEach(func() {
		pluginCreateOptions.SystemCallExec = util.FakeSystemCallExecSuccess
		pluginCreateOptions.LookPathContext = util.FakeLookPath
LinuxSuRen's avatar
LinuxSuRen 已提交
19
		data, err := GenerateSampleConfig()
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
		Expect(err).To(BeNil())
		rootOptions.ConfigFile = "test.yaml"
		err = ioutil.WriteFile(rootOptions.ConfigFile, data, 0664)
		Expect(err).To(BeNil())
	})

	JustBeforeEach(func() {
		rootCmd.SetArgs([]string{"plugin", "create", "--debug-output"})
		_, err = rootCmd.ExecuteC()
	})

	AfterEach(func() {
		os.Remove(rootOptions.ConfigFile)
	})

	It("should success", func() {
		Expect(err).NotTo(HaveOccurred())
	})
})