@ -65,10 +65,7 @@ func TestStdHandler(t *testing.T) {
testErr = errors . New ( "test error" )
testErr = errors . New ( "test error" )
bgCtx = context . Background ( )
bgCtx = context . Background ( )
// canceledCtx, cancel = context.WithCancel(bgCtx)
// canceledCtx, cancel = context.WithCancel(bgCtx)
clock = tstest . Clock {
startTime = time . Unix ( 1687870000 , 1234 )
Start : time . Now ( ) ,
Step : time . Second ,
}
)
)
// cancel()
// cancel()
@ -86,7 +83,7 @@ func TestStdHandler(t *testing.T) {
r : req ( bgCtx , "http://example.com/" ) ,
r : req ( bgCtx , "http://example.com/" ) ,
wantCode : 200 ,
wantCode : 200 ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
TLS : false ,
TLS : false ,
@ -103,7 +100,7 @@ func TestStdHandler(t *testing.T) {
r : req ( bgCtx , "http://example.com/foo" ) ,
r : req ( bgCtx , "http://example.com/foo" ) ,
wantCode : 404 ,
wantCode : 404 ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
Host : "example.com" ,
Host : "example.com" ,
@ -119,7 +116,7 @@ func TestStdHandler(t *testing.T) {
r : req ( bgCtx , "http://example.com/foo" ) ,
r : req ( bgCtx , "http://example.com/foo" ) ,
wantCode : 404 ,
wantCode : 404 ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
Host : "example.com" ,
Host : "example.com" ,
@ -136,7 +133,7 @@ func TestStdHandler(t *testing.T) {
r : req ( bgCtx , "http://example.com/foo" ) ,
r : req ( bgCtx , "http://example.com/foo" ) ,
wantCode : 404 ,
wantCode : 404 ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
Host : "example.com" ,
Host : "example.com" ,
@ -153,7 +150,7 @@ func TestStdHandler(t *testing.T) {
r : req ( bgCtx , "http://example.com/foo" ) ,
r : req ( bgCtx , "http://example.com/foo" ) ,
wantCode : 500 ,
wantCode : 500 ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
Host : "example.com" ,
Host : "example.com" ,
@ -170,7 +167,7 @@ func TestStdHandler(t *testing.T) {
r : req ( bgCtx , "http://example.com/foo" ) ,
r : req ( bgCtx , "http://example.com/foo" ) ,
wantCode : 500 ,
wantCode : 500 ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
Host : "example.com" ,
Host : "example.com" ,
@ -187,7 +184,7 @@ func TestStdHandler(t *testing.T) {
r : req ( bgCtx , "http://example.com/foo" ) ,
r : req ( bgCtx , "http://example.com/foo" ) ,
wantCode : 500 ,
wantCode : 500 ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
Host : "example.com" ,
Host : "example.com" ,
@ -204,7 +201,7 @@ func TestStdHandler(t *testing.T) {
r : req ( bgCtx , "http://example.com/foo" ) ,
r : req ( bgCtx , "http://example.com/foo" ) ,
wantCode : 200 ,
wantCode : 200 ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
Host : "example.com" ,
Host : "example.com" ,
@ -221,7 +218,7 @@ func TestStdHandler(t *testing.T) {
r : req ( bgCtx , "http://example.com/foo" ) ,
r : req ( bgCtx , "http://example.com/foo" ) ,
wantCode : 200 ,
wantCode : 200 ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
Host : "example.com" ,
Host : "example.com" ,
@ -238,7 +235,7 @@ func TestStdHandler(t *testing.T) {
r : req ( bgCtx , "http://example.com/foo" ) ,
r : req ( bgCtx , "http://example.com/foo" ) ,
wantCode : 200 ,
wantCode : 200 ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
Host : "example.com" ,
Host : "example.com" ,
@ -260,7 +257,7 @@ func TestStdHandler(t *testing.T) {
r : req ( bgCtx , "http://example.com/foo" ) ,
r : req ( bgCtx , "http://example.com/foo" ) ,
wantCode : 200 ,
wantCode : 200 ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
@ -279,7 +276,7 @@ func TestStdHandler(t *testing.T) {
http . Error ( w , e . Msg , 200 )
http . Error ( w , e . Msg , 200 )
} ,
} ,
wantLog : AccessLogRecord {
wantLog : AccessLogRecord {
When : clock. Start ,
When : startTime ,
Seconds : 1.0 ,
Seconds : 1.0 ,
Proto : "HTTP/1.1" ,
Proto : "HTTP/1.1" ,
TLS : false ,
TLS : false ,
@ -302,7 +299,10 @@ func TestStdHandler(t *testing.T) {
t . Logf ( fmt , args ... )
t . Logf ( fmt , args ... )
}
}
clock . Reset ( )
clock := tstest . NewClock ( tstest . ClockOpts {
Start : startTime ,
Step : time . Second ,
} )
rec := noopHijacker { httptest . NewRecorder ( ) , false }
rec := noopHijacker { httptest . NewRecorder ( ) , false }
h := StdHandler ( test . rh , HandlerOptions { Logf : logf , Now : clock . Now , OnError : test . errHandler } )
h := StdHandler ( test . rh , HandlerOptions { Logf : logf , Now : clock . Now , OnError : test . errHandler } )