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

Side by Side Diff: go/src/infra/appengine/test-results/model/full_result_test.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
OLDNEW
(Empty)
1 package model
2
3 import (
4 "encoding/json"
5 "testing"
6
7 . "github.com/smartystreets/goconvey/convey"
8 )
9
10 func TestFullResult(t *testing.T) {
11 t.Parallel()
12
13 Convey("TestFullResult", t, func() {
14 runtime := 20.9
15 unexpected := true
16
17 leaf := FullTestLeaf{
18 Actual: []string{"PASS", "AUDIO", "CRASH"},
19 Expected: []string{"PASS", "CRASH"},
20 Runtime: &runtime,
21 Bugs: []string{"crbug.com/700", "crbug.com/900"},
22 Unexpected: &unexpected,
23 }
24
25 ft := FullTest{
26 "foo": &FullTestLeaf{
27 Actual: []string{"FLAKY"},
28 Expected: []string{"FLAKY"},
29 },
30 "bar": &FullTestLeaf{
31 Actual: []string{"IMAGE"},
32 Expected: []string{"CRASH"},
33 },
34 "baz": FullTest{
35 "qux": FullTest{
36 "baaz": &FullTestLeaf{
37 Actual: []string{"CRASH"},
38 Expected: []string{"CRASH", "AUD IO"},
39 },
40 },
41 "baax": &leaf,
42 },
43 }
44
45 chromiumrev := "45000"
46
47 fr := FullResult{
48 Version: 4,
49 Builder: "foo_builder",
50 BuildNumber: Number(1000),
51 SecondsEpoch: 6400000000,
52 Tests: ft,
53 FailuresByType: map[string]int{
54 "A": 5,
55 "Q": 11,
56 },
57 ChromiumRev: &chromiumrev,
58 }
59
60 Convey("FullTestLeaf", func() {
61 Convey("Marshal followed by unmarshal returns original", func() {
62 b, err := json.Marshal(&leaf)
63 So(err, ShouldBeNil)
64 var actual FullTestLeaf
65 So(json.Unmarshal(b, &actual), ShouldBeNil)
66 So(actual, ShouldResemble, leaf)
67 })
68 })
69
70 Convey("FullTest", func() {
71 Convey("Marshal followed by unmarshal returns original", func() {
72 b, err := json.Marshal(&ft)
73 So(err, ShouldBeNil)
74 var actual FullTest
75 So(json.Unmarshal(b, &actual), ShouldBeNil)
76 So(actual, ShouldResemble, ft)
77 })
78 })
79
80 Convey("FullResult", func() {
81 Convey("Marshal followed by unmarshal returns original", func() {
82 b, err := json.Marshal(&fr)
83 So(err, ShouldBeNil)
84 var actual FullResult
85 So(json.Unmarshal(b, &actual), ShouldBeNil)
86 So(actual, ShouldResemble, fr)
87 })
88 })
89
90 Convey("AggregateResult", func() {
91 Convey("basic converion", func() {
92 aggr, err := fr.AggregateResult()
93 So(err, ShouldBeNil)
94 So(aggr, ShouldResemble, AggregateResult{
95 Version: ResultsVersion,
96 Builder: fr.Builder,
97 BuilderInfo: &BuilderInfo{
98 SecondsEpoch: []int64{6400000000 },
99 BuildNumbers: []Number{1000},
100 FailureMap: FailureLongNames,
101 Tests: AggregateTest{
102 "foo": &AggregateTestLea f{
103 Results: []Resu ltSummary{{1, "L"}},
104 Runtimes: []Runt imeSummary{{1, 0}},
105 Expected: []stri ng{"FLAKY"},
106 },
107 "bar": &AggregateTestLea f{
108 Results: []Resu ltSummary{{1, "I"}},
109 Runtimes: []Runt imeSummary{{1, 0}},
110 Expected: []stri ng{"CRASH"},
111 },
112 "baz": AggregateTest{
113 "qux": Aggregate Test{
114 "baaz": &AggregateTestLeaf{
115 Results: []ResultSummary{{1, "C"}},
116 Runtimes: []RuntimeSummary{{1, 0}},
117 Expected: []string{"CRASH", "AUDIO"},
118 },
119 },
120 "baax": &Aggrega teTestLeaf{
121 Results: []ResultSummary{{1, "PAC"}},
122 Runtimes : []RuntimeSummary{{1, 20.9}},
123 Expected : []string{"PASS", "CRASH"},
124 Bugs: []string{"crbug.com/700", "crbug.com/900"},
125 },
126 },
127 },
128 FailuresByType: map[string][]int {
129 "A": {5},
130 "Q": {11},
131 },
132 ChromeRevs: []string{"45000"},
133 },
134 })
135 })
136 })
137 })
138 }
OLDNEW
« no previous file with comments | « go/src/infra/appengine/test-results/model/full_result.go ('k') | go/src/infra/appengine/test-results/model/masters_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698