github.com/ssgreg/logf@v1.4.1/context_test.go (about) 1 package logf 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestContext(t *testing.T) { 11 var logger *Logger 12 // Check if no logger is associated with the Context. 13 assert.Equal(t, logger, FromContext(context.Background())) 14 15 logger = NewDisabledLogger() 16 ctx := NewContext(context.Background(), logger) 17 // First try. 18 assert.Equal(t, logger, FromContext(ctx)) 19 // Second try. 20 assert.Equal(t, logger, FromContext(ctx)) 21 }