Ejemplo n.º 1
0
	for _, file := range files {
		os.Remove(dir.Name() + "/" + file.Name())
	}
}

var _ = BeforeSuite(func() {
	var err error

	RemoveDataFiles()
	dataPath := os.ExpandEnv("${GOPATH}/src/github.com/duskhacker/cqrsnu/data")

	command := exec.Command("nsqd", "--data-path="+dataPath, "--tcp-address=localhost:4150", "--http-address=localhost:4151", "--broadcast-address=localhost")
	serverSession, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)
	Expect(err).ToNot(HaveOccurred())
	Eventually(serverSession.Err, "2s").Should(gbytes.Say(`TCP: listening on`))

	cafe.SetConnectToNSQD(true)
	cafe.SetNsqdTCPAddr("localhost:4150")
	ChefTodoList = []*todoListGroup{}
	cafe.Init()
	Init()

})

var _ = AfterSuite(func() {
	cafe.StopAllConsumers()
	serverSession.Interrupt()
	gexec.CleanupBuildArtifacts()
})
Ejemplo n.º 2
0
					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)
Ejemplo n.º 3
0
	. "github.com/duskhacker/cqrsnu/internal/github.com/onsi/ginkgo/internal/writer"
	. "github.com/duskhacker/cqrsnu/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() {
Ejemplo n.º 4
0
			})
		})
	})

	Describe("Logging to the Writer", func() {
		var buf *gbytes.Buffer
		BeforeEach(func() {
			buf = gbytes.NewBuffer()
			s.Writer = buf
			s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {})
			s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {})
		})

		It("should write to the buffer when a request comes in", func() {
			http.Get(s.URL() + "/foo")
			Ω(buf).Should(gbytes.Say("GHTTP Received Request: GET - /foo\n"))

			http.Post(s.URL()+"/bar", "", nil)
			Ω(buf).Should(gbytes.Say("GHTTP Received Request: POST - /bar\n"))
		})
	})

	Describe("Request Handlers", func() {
		Describe("VerifyRequest", func() {
			BeforeEach(func() {
				s.AppendHandlers(VerifyRequest("GET", "/foo"))
			})

			It("should verify the method, path", func() {
				resp, err = http.Get(s.URL() + "/foo?baz=bar")
				Ω(err).ShouldNot(HaveOccurred())