Fix Poll(); yeyy tests
This commit is contained in:
parent
fe5734d9f0
commit
85939618c8
6 changed files with 63 additions and 4 deletions
|
@ -196,16 +196,17 @@ func (s *Server) Run() error {
|
|||
listenStr += fmt.Sprintf(" %s/https", s.config.ListenHTTPS)
|
||||
}
|
||||
log.Printf("Listening on %s", listenStr)
|
||||
http.HandleFunc("/", s.handle)
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", s.handle)
|
||||
errChan := make(chan error)
|
||||
s.mu.Lock()
|
||||
s.closeChan = make(chan bool)
|
||||
s.httpServer = &http.Server{Addr: s.config.ListenHTTP}
|
||||
s.httpServer = &http.Server{Addr: s.config.ListenHTTP, Handler: mux}
|
||||
go func() {
|
||||
errChan <- s.httpServer.ListenAndServe()
|
||||
}()
|
||||
if s.config.ListenHTTPS != "" {
|
||||
s.httpsServer = &http.Server{Addr: s.config.ListenHTTP}
|
||||
s.httpsServer = &http.Server{Addr: s.config.ListenHTTP, Handler: mux}
|
||||
go func() {
|
||||
errChan <- s.httpsServer.ListenAndServeTLS(s.config.CertFile, s.config.KeyFile)
|
||||
}()
|
||||
|
|
|
@ -487,6 +487,27 @@ func TestServer_SubscribeWithQueryFilters(t *testing.T) {
|
|||
require.Equal(t, keepaliveEvent, messages[2].Event)
|
||||
}
|
||||
|
||||
/*
|
||||
func TestServer_Curl_Publish_Poll(t *testing.T) {
|
||||
s, port := test.StartServer(t)
|
||||
defer test.StopServer(t, s, port)
|
||||
|
||||
cmd := exec.Command("sh", "-c", fmt.Sprintf(`curl -sd "This is a test" localhost:%d/mytopic`, port))
|
||||
require.Nil(t, cmd.Run())
|
||||
b, err := cmd.CombinedOutput()
|
||||
require.Nil(t, err)
|
||||
msg := toMessage(t, string(b))
|
||||
require.Equal(t, "This is a test", msg.Message)
|
||||
|
||||
cmd = exec.Command("sh", "-c", fmt.Sprintf(`curl "localhost:%d/mytopic?poll=1"`, port))
|
||||
require.Nil(t, cmd.Run())
|
||||
b, err = cmd.CombinedOutput()
|
||||
require.Nil(t, err)
|
||||
msg = toMessage(t, string(b))
|
||||
require.Equal(t, "This is a test", msg.Message)
|
||||
}
|
||||
*/
|
||||
|
||||
func newTestConfig(t *testing.T) *Config {
|
||||
conf := NewConfig()
|
||||
conf.CacheFile = filepath.Join(t.TempDir(), "cache.db")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue