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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « go/src/infra/monorail/validation.go ('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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package monorail
6
7 import (
8 "testing"
9
10 . "github.com/smartystreets/goconvey/convey"
11 )
12
13 func TestValidation(t *testing.T) {
14 t.Parallel()
15
16 Convey("Validation", t, func() {
17 type Validatable interface {
18 Validate() error
19 }
20 good := func(v Validatable) {
21 So(v.Validate(), ShouldBeNil)
22 }
23 bad := func(v Validatable) {
24 So(v.Validate(), ShouldNotBeNil)
25 }
26
27 Convey("IssueRef", func() {
28 good(&IssueRef{ProjectId: "chromium", IssueId: 1})
29 bad((*IssueRef)(nil))
30 bad(&IssueRef{})
31 bad(&IssueRef{ProjectId: "chromium"})
32 bad(&IssueRef{IssueId: 1})
33 })
34
35 Convey("AtomPerson", func() {
36 good(&AtomPerson{Name: "bob"})
37 bad((*AtomPerson)(nil))
38 bad(&AtomPerson{})
39 })
40
41 Convey("Issue", func() {
42 good(&Issue{Status: StatusStarted})
43 good(&Issue{
44 Summary: "Write tests for monorail client",
45 Author: &AtomPerson{"seanmccullough@chromiu m.org"},
46 Owner: &AtomPerson{"nodir@chromium.org"},
47 Status: StatusStarted,
48 Cc: []*AtomPerson{{"agable@chromium.org "}},
49 Description: "We should keep our code coverage h igh, so write tests",
50 Components: []string{"Infra"},
51 Labels: []string{"M-53"},
52 })
53
54 bad((*Issue)(nil))
55 bad(&Issue{})
56 bad(&Issue{
57 Status: StatusStarted,
58 BlockedOn: []*IssueRef{{}},
59 })
60 bad(&Issue{
61 Status: StatusStarted,
62 Cc: []*AtomPerson{{Name: "a"}, {Name: "a"}},
63 })
64 bad(&Issue{
65 Status: StatusStarted,
66 Components: []string{""},
67 })
68 bad(&Issue{
69 Status: StatusStarted,
70 Labels: []string{""},
71 })
72 bad(&Issue{
73 Status: StatusStarted,
74 Owner: &AtomPerson{},
75 })
76 })
77 Convey("InsertIssueRequest", func() {
78 good(&InsertIssueRequest{
79 ProjectId: "chromium",
80 Issue: &Issue{
81 Summary: "Write tests for monorail c lient",
82 Author: &AtomPerson{"seanmccullough @chromium.org"},
83 Owner: &AtomPerson{"nodir@chromium .org"},
84 Status: StatusStarted,
85 Cc: []*AtomPerson{{"agable@chro mium.org"}},
86 Description: "We should keep our code co verage high, so write tests",
87 Components: []string{"Infra"},
88 Labels: []string{"M-53"},
89 },
90 })
91
92 bad(&InsertIssueRequest{})
93 bad(&InsertIssueRequest{
94 ProjectId: "chromium",
95 Issue: &Issue {
96 Status: StatusStarted,
97 Id: 1,
98 },
99 })
100 })
101 })
102 }
OLDNEW
« 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