コード例 #1
0
ファイル: writer_test.go プロジェクト: viovanov/bosh-agent
	. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo/internal/writer"
	. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega"
)

var _ = Describe("Writer", func() {
	var writer *Writer
	var out *gbytes.Buffer

	BeforeEach(func() {
		out = gbytes.NewBuffer()
		writer = New(out)
	})

	It("should stream directly to the outbuffer by default", func() {
		writer.Write([]byte("foo"))
		Ω(out).Should(gbytes.Say("foo"))
	})

	It("should not emit the header when asked to DumpOutWitHeader", func() {
		writer.Write([]byte("foo"))
		writer.DumpOutWithHeader("my header")
		Ω(out).ShouldNot(gbytes.Say("my header"))
		Ω(out).Should(gbytes.Say("foo"))
	})

	Context("when told not to stream", func() {
		BeforeEach(func() {
			writer.SetStream(false)
		})

		It("should only write to the buffer when told to DumpOut", func() {
コード例 #2
0
ファイル: spec_test.go プロジェクト: viovanov/bosh-agent
					newContainer("outer container", noneFlag,
						newBef("outer bef A", false),
						newJusBef("outer jusbef A", false),
						newAft("outer aft A", false),
					),
					newContainer("inner container", noneFlag,
						newBef("inner bef A", false),
						newJusBef("inner jusbef A", false),
						newAft("inner aft A", false),
					),
				),
				true,
			)
			spec.Run(buffer)

			Ω(buffer).Should(gbytes.Say(`\[BeforeEach\] outer container`))
			Ω(buffer).Should(gbytes.Say(`\[BeforeEach\] inner container`))
			Ω(buffer).Should(gbytes.Say(`\[JustBeforeEach\] outer container`))
			Ω(buffer).Should(gbytes.Say(`\[JustBeforeEach\] inner container`))
			Ω(buffer).Should(gbytes.Say(`\[It\] it node`))
			Ω(buffer).Should(gbytes.Say(`\[AfterEach\] inner container`))
			Ω(buffer).Should(gbytes.Say(`\[AfterEach\] outer container`))
		})

		It("should emit progress to the writer as it runs Befores, JustBefores, Afters, and Measures", func() {
			spec = New(
				newMeasure("measure node", noneFlag, false, 2),
				containers(),
				true,
			)
			spec.Run(buffer)
コード例 #3
0
ファイル: main_test.go プロジェクト: viovanov/bosh-agent
			path := "/tarball.tgz"
			url := "https://localhost:9003" + path
			cmd := exec.Command(
				bin,
				"download",
				url,
				"-certFile", spec.FixtureFilename("certs/bootstrapper.crt"),
				"-keyFile", spec.FixtureFilename("certs/bootstrapper.key"),
				"-caPemFile", spec.FixtureFilename("certs/rootCA.pem"),
				"-allowedName", "*",
			)
			var startErr error
			session, startErr = gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
			Expect(startErr).ToNot(HaveOccurred())
			Eventually(session).Should(gexec.Exit(0))
			Expect(session.Out).To(gbytes.Say("hello from install script"))
			Expect(session.Out).To(gbytes.Say("Download succeeded"))
		})
	})

	Describe("listen", func() {
		var session *gexec.Session
		var port = 4443 + GinkgoParallelNode()
		var url = fmt.Sprintf("https://localhost:%d/self-update", port)

		BeforeEach(func() {
			cmd := exec.Command(
				bin,
				"listen",
				strconv.Itoa(port),
				"-certFile", spec.FixtureFilename("certs/bootstrapper.crt"),