github.com/mailgun/holster/v4@v4.20.0/ctxutil/context_test.go (about) 1 package ctxutil_test 2 3 import ( 4 "context" 5 "testing" 6 "time" 7 8 "github.com/mailgun/holster/v4/ctxutil" 9 "github.com/stretchr/testify/require" 10 ) 11 12 func TestWithDeadline(t *testing.T) { 13 t.Run("Happy path", func(t *testing.T) { 14 ctx := context.Background() 15 deadline := time.Now().Add(1 * time.Hour) 16 ctx2, cancel := ctxutil.WithDeadline(ctx, deadline) 17 cancel() 18 require.NotNil(t, ctx2) 19 }) 20 } 21 22 func TestWithTimeout(t *testing.T) { 23 t.Run("Happy path", func(t *testing.T) { 24 ctx := context.Background() 25 timeout := 1 * time.Hour 26 ctx2, cancel := ctxutil.WithTimeout(ctx, timeout) 27 cancel() 28 require.NotNil(t, ctx2) 29 }) 30 }