github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/testing/time.go (about) 1 // Copyright 2018 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package testing 5 6 import ( 7 "time" 8 ) 9 10 // ZeroTime can be used in tests instead of time.Now() when the returned 11 // time.Time value is not relevant. 12 // 13 // Example: instead of now := time.Now() use now := testing.ZeroTime(). 14 func ZeroTime() time.Time { 15 return time.Time{} 16 } 17 18 // NonZeroTime can be used in tests instead of time.Now() when the returned 19 // time.Time value must be non-zero (its IsZero() method returns false). 20 func NonZeroTime() time.Time { 21 return time.Unix(0, 1) // 1 nanosecond since epoch 22 }