~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/testing/time.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package testing
 
2
 
 
3
import (
 
4
        "time"
 
5
)
 
6
 
 
7
// ZeroTime can be used in tests instead of time.Now() when the returned
 
8
// time.Time value is not relevant.
 
9
//
 
10
// Example: instead of now := time.Now() use now := testing.ZeroTime().
 
11
func ZeroTime() time.Time {
 
12
        return time.Time{}
 
13
}
 
14
 
 
15
// NonZeroTime can be used in tests instead of time.Now() when the returned
 
16
// time.Time value must be non-zero (its IsZero() method returns false).
 
17
func NonZeroTime() time.Time {
 
18
        return time.Unix(0, 1) // 1 nanosecond since epoch
 
19
}