github.com/blend/go-sdk@v1.20220411.3/cron/once_at_test.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package cron 9 10 import ( 11 "fmt" 12 "testing" 13 "time" 14 15 "github.com/blend/go-sdk/assert" 16 ) 17 18 func Test_OnceAtUTC(t *testing.T) { 19 assert := assert.New(t) 20 21 fireAt := time.Date(2018, 10, 21, 12, 00, 00, 00, time.UTC) 22 before := fireAt.Add(-time.Minute) 23 after := fireAt.Add(time.Minute) 24 25 s := OnceAtUTC(fireAt) 26 result := s.Next(before) 27 assert.Equal(result, fireAt) 28 29 result = s.Next(after) 30 assert.True(result.IsZero()) 31 } 32 33 func Test_OnceAtUTC_String(t *testing.T) { 34 t.Parallel() 35 its := assert.New(t) 36 37 ts := time.Now().UTC() 38 39 its.Equal( 40 fmt.Sprintf("%s %s", StringScheduleOnceAt, ts.Format(time.RFC3339)), 41 OnceAtUTC(ts).String(), 42 ) 43 }