diff options
Diffstat (limited to 'skate/reduce.go')
-rw-r--r-- | skate/reduce.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/skate/reduce.go b/skate/reduce.go index ec582c6..6c86b92 100644 --- a/skate/reduce.go +++ b/skate/reduce.go @@ -32,6 +32,9 @@ import ( "github.com/segmentio/encoding/json" ) +// timeNow is used for mocking time in tests. +var timeNow = time.Now + // groupLogf logs a message alongsize a serialized group for debugging. func groupLogf(g *zipkey.Group, s string, vs ...interface{}) { log.Printf(s, vs...) @@ -66,7 +69,7 @@ func ZippyExact(releases, refs io.Reader, matchResult MatchResult, w io.Writer) } bref.Reset() bref.Key = fmt.Sprintf("%s_%d", ref.ReleaseIdent, ref.Index+1) - bref.IndexedTs = time.Now().UTC().Format(time.RFC3339) + bref.IndexedTs = timeNow().UTC().Format(time.RFC3339) bref.SourceReleaseIdent = ref.ReleaseIdent bref.SourceWorkIdent = ref.WorkIdent bref.SourceReleaseStage = ref.ReleaseStage @@ -493,7 +496,7 @@ func matchedRefsExtend(matched []*BiblioRef, refs []*Ref, stats *statsAugment) [ continue } var bref BiblioRef - bref.IndexedTs = time.Now().UTC().Format(time.RFC3339) + bref.IndexedTs = timeNow().UTC().Format(time.RFC3339) bref.Key = fmt.Sprintf("%s_%d", r.ReleaseIdent, r.Index) bref.RefIndex = r.Index bref.RefKey = r.Key @@ -525,7 +528,7 @@ func uniqueMatches(docs []string, stats *statsAugment) (result []*BiblioRef, err // On-the-fly add elasticsearch "_id" and indexed timestamp, if not already set. if bref.Key == "" && bref.SourceReleaseIdent != "" { bref.Key = fmt.Sprintf("%s_%d", bref.SourceReleaseIdent, bref.RefIndex) - bref.IndexedTs = time.Now().UTC().Format(time.RFC3339) + bref.IndexedTs = timeNow().UTC().Format(time.RFC3339) } brefs = append(brefs, &bref) } |