Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DiscardTracer *apm.Tracer
DiscardTracer is an apm.Tracer that discards all events.
This tracer may be used by multiple tests, and so should not be modified or closed.
Functions ¶
func WithTransaction ¶
WithTransaction is equivalent to calling WithTransactionOptions with a zero TransactionOptions.
func WithTransactionOptions ¶ added in v1.1.0
func WithTransactionOptions(opts apm.TransactionOptions, f func(ctx context.Context)) (model.Transaction, []model.Span, []model.Error)
WithTransactionOptions calls f with a new context containing a transaction and transaction options, flushes the transaction to a test server, and returns the decoded transaction and any associated spans and errors.
Types ¶
type HTTPTestSuite ¶
type HTTPTestSuite struct { suite.Suite // Handler holds an instrumented HTTP handler. Handler must // support the following routes: // // GET /implicit_write (no explicit write on the response) // GET /panic_before_write (panic without writing response) // GET /panic_after_write (panic after writing response) // Handler http.Handler // Tracer is the apm.Tracer used to instrument Handler. // // HTTPTestSuite will close the tracer when all tests have // been completed. Tracer *apm.Tracer // Recorder is the transport used as the transport for Tracer. Recorder *transporttest.RecorderTransport // contains filtered or unexported fields }
HTTPTestSuite is a test suite for HTTP instrumentation modules.
func (*HTTPTestSuite) SetupSuite ¶
func (s *HTTPTestSuite) SetupSuite()
SetupSuite runs before the tests in the suite are run.
func (*HTTPTestSuite) SetupTest ¶
func (s *HTTPTestSuite) SetupTest()
SetupTest runs before each test.
func (*HTTPTestSuite) TearDownSuite ¶
func (s *HTTPTestSuite) TearDownSuite()
TearDownSuite runs after the tests in the suite are run.
func (*HTTPTestSuite) TestImplicitWrite ¶
func (s *HTTPTestSuite) TestImplicitWrite()
TestImplicitWrite tests the behaviour of instrumented handlers for routes which do not explicitly write a response, but instead leave it to the framework to write an empty 200 response.
func (*HTTPTestSuite) TestPanicAfterWrite ¶
func (s *HTTPTestSuite) TestPanicAfterWrite()
TestPanicAfterWrite tests the behaviour of instrumented handlers for routes which panic after writing headers. The handler is expected to recover the panic without otherwise affecting the response.
func (*HTTPTestSuite) TestPanicBeforeWrite ¶
func (s *HTTPTestSuite) TestPanicBeforeWrite()
TestPanicBeforeWrite tests the behaviour of instrumented handlers for routes which panic before any headers are written. The handler is expected to recover the panic and write an empty 500 response.
type LogfLogger ¶
type LogfLogger interface {
Logf(string, ...interface{})
}
LogfLogger is an interface with the a Logf method, implemented by *testing.T and *testing.B.
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
TestLogger is an implementation of apm.Logger, logging to a testing.T.
func NewTestLogger ¶
func NewTestLogger(l LogfLogger) TestLogger
NewTestLogger returns a new TestLogger that logs messages to l.
func (TestLogger) Debugf ¶
func (t TestLogger) Debugf(format string, args ...interface{})
Debugf logs debug messages.
func (TestLogger) Errorf ¶
func (t TestLogger) Errorf(format string, args ...interface{})
Errorf logs error messages.