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

Unified Diff: go/src/infra/monorail/validation_test.go

Issue 2037143002: Monorail client in Go (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: more tests Created 4 years, 6 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
« no previous file with comments | « go/src/infra/monorail/validation.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/monorail/validation_test.go
diff --git a/go/src/infra/monorail/validation_test.go b/go/src/infra/monorail/validation_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..c52453518c07dc766fb3163756c8b7dcef955c33
--- /dev/null
+++ b/go/src/infra/monorail/validation_test.go
@@ -0,0 +1,102 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package monorail
+
+import (
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestValidation(t *testing.T) {
+ t.Parallel()
+
+ Convey("Validation", t, func() {
+ type Validatable interface {
+ Validate() error
+ }
+ good := func(v Validatable) {
+ So(v.Validate(), ShouldBeNil)
+ }
+ bad := func(v Validatable) {
+ So(v.Validate(), ShouldNotBeNil)
+ }
+
+ Convey("IssueRef", func() {
+ good(&IssueRef{ProjectId: "chromium", IssueId: 1})
+ bad((*IssueRef)(nil))
+ bad(&IssueRef{})
+ bad(&IssueRef{ProjectId: "chromium"})
+ bad(&IssueRef{IssueId: 1})
+ })
+
+ Convey("AtomPerson", func() {
+ good(&AtomPerson{Name: "bob"})
+ bad((*AtomPerson)(nil))
+ bad(&AtomPerson{})
+ })
+
+ Convey("Issue", func() {
+ good(&Issue{Status: StatusStarted})
+ good(&Issue{
+ Summary: "Write tests for monorail client",
+ Author: &AtomPerson{"seanmccullough@chromium.org"},
+ Owner: &AtomPerson{"nodir@chromium.org"},
+ Status: StatusStarted,
+ Cc: []*AtomPerson{{"agable@chromium.org"}},
+ Description: "We should keep our code coverage high, so write tests",
+ Components: []string{"Infra"},
+ Labels: []string{"M-53"},
+ })
+
+ bad((*Issue)(nil))
+ bad(&Issue{})
+ bad(&Issue{
+ Status: StatusStarted,
+ BlockedOn: []*IssueRef{{}},
+ })
+ bad(&Issue{
+ Status: StatusStarted,
+ Cc: []*AtomPerson{{Name: "a"}, {Name: "a"}},
+ })
+ bad(&Issue{
+ Status: StatusStarted,
+ Components: []string{""},
+ })
+ bad(&Issue{
+ Status: StatusStarted,
+ Labels: []string{""},
+ })
+ bad(&Issue{
+ Status: StatusStarted,
+ Owner: &AtomPerson{},
+ })
+ })
+ Convey("InsertIssueRequest", func() {
+ good(&InsertIssueRequest{
+ ProjectId: "chromium",
+ Issue: &Issue{
+ Summary: "Write tests for monorail client",
+ Author: &AtomPerson{"seanmccullough@chromium.org"},
+ Owner: &AtomPerson{"nodir@chromium.org"},
+ Status: StatusStarted,
+ Cc: []*AtomPerson{{"agable@chromium.org"}},
+ Description: "We should keep our code coverage high, so write tests",
+ Components: []string{"Infra"},
+ Labels: []string{"M-53"},
+ },
+ })
+
+ bad(&InsertIssueRequest{})
+ bad(&InsertIssueRequest{
+ ProjectId: "chromium",
+ Issue: &Issue {
+ Status: StatusStarted,
+ Id: 1,
+ },
+ })
+ })
+ })
+}
« no previous file with comments | « go/src/infra/monorail/validation.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698