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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: go/src/infra/appengine/test-results/model/full_result_test.go
diff --git a/go/src/infra/appengine/test-results/model/full_result_test.go b/go/src/infra/appengine/test-results/model/full_result_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..78c94e59de7d9519c1730eb929741b5c38df9753
--- /dev/null
+++ b/go/src/infra/appengine/test-results/model/full_result_test.go
@@ -0,0 +1,138 @@
+package model
+
+import (
+ "encoding/json"
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestFullResult(t *testing.T) {
+ t.Parallel()
+
+ Convey("TestFullResult", t, func() {
+ runtime := 20.9
+ unexpected := true
+
+ leaf := FullTestLeaf{
+ Actual: []string{"PASS", "AUDIO", "CRASH"},
+ Expected: []string{"PASS", "CRASH"},
+ Runtime: &runtime,
+ Bugs: []string{"crbug.com/700", "crbug.com/900"},
+ Unexpected: &unexpected,
+ }
+
+ ft := FullTest{
+ "foo": &FullTestLeaf{
+ Actual: []string{"FLAKY"},
+ Expected: []string{"FLAKY"},
+ },
+ "bar": &FullTestLeaf{
+ Actual: []string{"IMAGE"},
+ Expected: []string{"CRASH"},
+ },
+ "baz": FullTest{
+ "qux": FullTest{
+ "baaz": &FullTestLeaf{
+ Actual: []string{"CRASH"},
+ Expected: []string{"CRASH", "AUDIO"},
+ },
+ },
+ "baax": &leaf,
+ },
+ }
+
+ chromiumrev := "45000"
+
+ fr := FullResult{
+ Version: 4,
+ Builder: "foo_builder",
+ BuildNumber: Number(1000),
+ SecondsEpoch: 6400000000,
+ Tests: ft,
+ FailuresByType: map[string]int{
+ "A": 5,
+ "Q": 11,
+ },
+ ChromiumRev: &chromiumrev,
+ }
+
+ Convey("FullTestLeaf", func() {
+ Convey("Marshal followed by unmarshal returns original", func() {
+ b, err := json.Marshal(&leaf)
+ So(err, ShouldBeNil)
+ var actual FullTestLeaf
+ So(json.Unmarshal(b, &actual), ShouldBeNil)
+ So(actual, ShouldResemble, leaf)
+ })
+ })
+
+ Convey("FullTest", func() {
+ Convey("Marshal followed by unmarshal returns original", func() {
+ b, err := json.Marshal(&ft)
+ So(err, ShouldBeNil)
+ var actual FullTest
+ So(json.Unmarshal(b, &actual), ShouldBeNil)
+ So(actual, ShouldResemble, ft)
+ })
+ })
+
+ Convey("FullResult", func() {
+ Convey("Marshal followed by unmarshal returns original", func() {
+ b, err := json.Marshal(&fr)
+ So(err, ShouldBeNil)
+ var actual FullResult
+ So(json.Unmarshal(b, &actual), ShouldBeNil)
+ So(actual, ShouldResemble, fr)
+ })
+ })
+
+ Convey("AggregateResult", func() {
+ Convey("basic converion", func() {
+ aggr, err := fr.AggregateResult()
+ So(err, ShouldBeNil)
+ So(aggr, ShouldResemble, AggregateResult{
+ Version: ResultsVersion,
+ Builder: fr.Builder,
+ BuilderInfo: &BuilderInfo{
+ SecondsEpoch: []int64{6400000000},
+ BuildNumbers: []Number{1000},
+ FailureMap: FailureLongNames,
+ Tests: AggregateTest{
+ "foo": &AggregateTestLeaf{
+ Results: []ResultSummary{{1, "L"}},
+ Runtimes: []RuntimeSummary{{1, 0}},
+ Expected: []string{"FLAKY"},
+ },
+ "bar": &AggregateTestLeaf{
+ Results: []ResultSummary{{1, "I"}},
+ Runtimes: []RuntimeSummary{{1, 0}},
+ Expected: []string{"CRASH"},
+ },
+ "baz": AggregateTest{
+ "qux": AggregateTest{
+ "baaz": &AggregateTestLeaf{
+ Results: []ResultSummary{{1, "C"}},
+ Runtimes: []RuntimeSummary{{1, 0}},
+ Expected: []string{"CRASH", "AUDIO"},
+ },
+ },
+ "baax": &AggregateTestLeaf{
+ Results: []ResultSummary{{1, "PAC"}},
+ Runtimes: []RuntimeSummary{{1, 20.9}},
+ Expected: []string{"PASS", "CRASH"},
+ Bugs: []string{"crbug.com/700", "crbug.com/900"},
+ },
+ },
+ },
+ FailuresByType: map[string][]int{
+ "A": {5},
+ "Q": {11},
+ },
+ ChromeRevs: []string{"45000"},
+ },
+ })
+ })
+ })
+ })
+}
« 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