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

Unified Diff: go/src/infra/appengine/test-results/model/common_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/common_test.go
diff --git a/go/src/infra/appengine/test-results/model/common_test.go b/go/src/infra/appengine/test-results/model/common_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..6f15cc437a127610dcd60e48f9ec54daf503168c
--- /dev/null
+++ b/go/src/infra/appengine/test-results/model/common_test.go
@@ -0,0 +1,46 @@
+package model
+
+import (
+ "encoding/json"
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestCommon(t *testing.T) {
+ t.Parallel()
+
+ Convey("Number", t, func() {
+ Convey("UnmarshalJSON", func() {
+ Convey("fails on non integers", func() {
+ Convey("string", func() {
+ input := []byte("foo")
+ var num Number
+ So(json.Unmarshal(input, &num), ShouldNotBeNil)
+ })
+
+ Convey("float", func() {
+ input := []byte("2.0")
+ var num Number
+ So(json.Unmarshal(input, &num), ShouldNotBeNil)
+ })
+ })
+
+ Convey("succeeds for integer", func() {
+ input := []byte("-400")
+ var num Number
+ So(json.Unmarshal(input, &num), ShouldBeNil)
+ So(num, ShouldEqual, -400)
+ })
+ })
+
+ Convey("MarshalJSON", func() {
+ Convey("basic", func() {
+ num := Number(-400)
+ b, err := json.Marshal(&num)
+ So(err, ShouldBeNil)
+ So(string(b), ShouldEqual, "-400")
+ })
+ })
+ })
+}
« no previous file with comments | « go/src/infra/appengine/test-results/model/common.go ('k') | go/src/infra/appengine/test-results/model/full_result.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698