Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: go/src/infra/appengine/test-results/model/test_file.go

Issue 2234353002: test-results: package model: Add full_result.go and tests (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Improve coverage Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « go/src/infra/appengine/test-results/model/model.infra_testing ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package model 1 package model
2 2
3 import ( 3 import (
4 "bytes" 4 "bytes"
5 "fmt" 5 "fmt"
6 "io" 6 "io"
7 "io/ioutil" 7 "io/ioutil"
8 "math" 8 "math"
9 "time" 9 "time"
10 10
11 "golang.org/x/net/context" 11 "golang.org/x/net/context"
12 12
13 "github.com/luci/gae/service/datastore" 13 "github.com/luci/gae/service/datastore"
14 "github.com/luci/luci-go/common/errors" 14 "github.com/luci/luci-go/common/errors"
15 "github.com/luci/luci-go/common/logging" 15 "github.com/luci/luci-go/common/logging"
16 ) 16 )
17 17
18 // IsAggregateTestFile returns whether filename is that of an aggregate test fil e. 18 // IsAggregateTestFile returns whether filename is that of an aggregate test fil e.
19 func IsAggregateTestFile(filename string) bool { 19 func IsAggregateTestFile(filename string) bool {
20 switch filename { 20 switch filename {
21 case "results.json", "results-small.json": 21 case "results.json", "results-small.json":
22 return true 22 return true
23 default: 23 default:
24 return false 24 return false
25 } 25 }
26 } 26 }
27 27
28 // BuildNum is int64 that is used to handle TestFile datastore records 28 // BuildNum is int64 that is used to handle TestFile datastore records
29 // with null build_number. 29 // with null build_number. The value is >= 0 if the datastore value
30 // was not null.
30 type BuildNum int64 31 type BuildNum int64
31 32
32 var _ datastore.PropertyConverter = (*BuildNum)(nil) 33 var _ datastore.PropertyConverter = (*BuildNum)(nil)
33 34
35 // IsNil returns whether b had null value in datastore.
34 func (b *BuildNum) IsNil() bool { return *b == -1 } 36 func (b *BuildNum) IsNil() bool { return *b == -1 }
35 37
38 // ToProperty is for implementing datastore.PropertyConverter.
36 func (b *BuildNum) ToProperty() (p datastore.Property, err error) { 39 func (b *BuildNum) ToProperty() (p datastore.Property, err error) {
37 if b.IsNil() { 40 if b.IsNil() {
38 return 41 return
39 } 42 }
40 p = datastore.MkProperty(*b) 43 p = datastore.MkProperty(*b)
41 return 44 return
42 } 45 }
43 46
47 // FromProperty is for implementing datastore.PropertyConverter.
44 func (b *BuildNum) FromProperty(p datastore.Property) error { 48 func (b *BuildNum) FromProperty(p datastore.Property) error {
45 switch p.Type() { 49 switch p.Type() {
46 case datastore.PTNull: 50 case datastore.PTNull:
47 *b = -1 51 *b = -1
48 case datastore.PTInt: 52 case datastore.PTInt:
49 *b = BuildNum(p.Value().(int64)) 53 *b = BuildNum(p.Value().(int64))
50 default: 54 default:
51 return fmt.Errorf("wrong type for property: %s", p.Type()) 55 return fmt.Errorf("wrong type for property: %s", p.Type())
52 } 56 }
53 return nil 57 return nil
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 q = q.Order("-date") 316 q = q.Order("-date")
313 317
314 if p.Limit < 0 || p.Limit > defaultLimit { 318 if p.Limit < 0 || p.Limit > defaultLimit {
315 q = q.Limit(defaultLimit) 319 q = q.Limit(defaultLimit)
316 } else { 320 } else {
317 q = q.Limit(p.Limit) 321 q = q.Limit(p.Limit)
318 } 322 }
319 323
320 return q 324 return q
321 } 325 }
OLDNEW
« no previous file with comments | « go/src/infra/appengine/test-results/model/model.infra_testing ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698