Ejemplo n.º 1
0
		var queuedRequests int

		BeforeEach(func() {
			listener = newHistoryListener("tcp", "127.0.0.1:0")
			serveMux = http.NewServeMux()
			server = httptest.NewUnstartedServer(serveMux)
			dialer = &net.Dialer{Timeout: 1 * time.Second}
			timeout = 0
			queuedRequests = 1
		})

		JustBeforeEach(func() {
			requestChan = make(chan []byte, queuedRequests)
			serveMux.HandleFunc("/234-bxg-234/", syslogHandler(requestChan))
			server.Listener = listener
			server.StartTLS()
		})

		AfterEach(func() {
			server.Close()
		})

		It("HTTP POSTs each log message to the HTTPS syslog endpoint", func() {
			outputUrl, _ := url.Parse(server.URL + "/234-bxg-234/")

			w, _ := syslogwriter.NewHttpsWriter(outputUrl, "appId", true, dialer, timeout)
			err := w.Connect()
			Expect(err).ToNot(HaveOccurred())

			parsedTime, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05Z")
			byteCount, err := w.Write(standardErrorPriority, []byte("Message"), "just a test", "TEST", parsedTime.UnixNano())