github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/apiserver/logsink/export_test.go (about)

     1  // Copyright 2015-2017 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package logsink
     5  
     6  import (
     7  	"net/http"
     8  
     9  	gc "gopkg.in/check.v1"
    10  )
    11  
    12  func NewHTTPHandlerForTest(
    13  	newLogWriteCloser NewLogWriteCloserFunc,
    14  	abort <-chan struct{},
    15  	ratelimit *RateLimitConfig,
    16  	metrics MetricsCollector,
    17  	modelUUID string,
    18  	makeChannel func() (chan struct{}, func()),
    19  ) http.Handler {
    20  	return &logSinkHandler{
    21  		newLogWriteCloser: newLogWriteCloser,
    22  		abort:             abort,
    23  		ratelimit:         ratelimit,
    24  		newStopChannel:    makeChannel,
    25  		metrics:           metrics,
    26  		modelUUID:         modelUUID,
    27  	}
    28  }
    29  
    30  func ReceiverStopped(c *gc.C, handler http.Handler) bool {
    31  	h, ok := handler.(*logSinkHandler)
    32  	c.Assert(ok, gc.Equals, true)
    33  	h.mu.Lock()
    34  	defer h.mu.Unlock()
    35  	return h.receiverStopped
    36  }