forked from jsantell/fx-devtools-bot
/
utils_test.go
181 lines (163 loc) · 6.05 KB
/
utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
package main
import (
"testing"
"github.com/google/go-github/github"
)
func createCommitMessage(message string) github.RepositoryCommit {
repoCommit := new(github.RepositoryCommit)
commit := new(github.Commit)
commit.Message = &message
repoCommit.Commit = commit
return *repoCommit
}
func TestIsValidCommit(t *testing.T) {
invalid := []string{
"merge fx-team to mozilla-central a=merge",
"Merge mozilla-central to fx-team",
"Bumping manifests a=b2g-bump",
"Bumping gaia.json for 2 gaia revision(s) a=gaia-bump",
"Backed out changeset e01dbdf8a218 (bug 1016613)",
}
valid := []string{
"Bug 1034670 - The canvas graphs should draw the background separately, r=pbrosset",
"Bug 1343: Support asm.js frames in SavedStacks. r=luke",
}
for _, str := range invalid {
if IsValidCommit(str) {
t.Error("Expected " + str + " to be an invalid commit.")
}
}
for _, str := range valid {
if !IsValidCommit(str) {
t.Error("Expected " + str + " to be a valid commit.")
}
}
}
func TestCreateMessage(t *testing.T) {
messages := [][]string{
[]string{
"Bug 1034670 - The canvas graphs should draw the background separately, r=pbrosset",
"The canvas graphs should draw the background separately http://bugzil.la/1034670",
},
[]string{
"Bug 1034670 - The canvas graphs should draw the background separately, a=pbrosset",
"The canvas graphs should draw the background separately http://bugzil.la/1034670",
},
[]string{
"Bug 1343: Support asm.js frames in SavedStacks. r=luke ",
"Support asm.js frames in SavedStacks http://bugzil.la/1343",
},
[]string{
"bug 1003450: Make all the cold trees mourn Their branches frozen in sightless motion Waving, reaching for the whipping rain There was silence And the firmament withdrew Revealing all, shapelessly and swiftly",
"Make all the cold trees mourn Their branches frozen in sightless motion Waving, reaching for the whipping rain T... http://bugzil.la/1003450",
},
[]string{
" Bug 1034668-The `getMappedSelection` method for all canvas graphs should clamp the selection bounds, r=pbrosset,someoneelse, space",
"The `getMappedSelection` method for all canvas graphs should clamp the selection bounds http://bugzil.la/1034668",
},
[]string{
`Bug 988314 - Rename Inspector tests and supporting documents. r=pbrosset
--HG--
rename : browser/devtools/inspector/test/browser_inspector_bug_817558_delete_node.js => browser/devtools/inspector/test/browser_inspector_delete-selected-node-01.js
rename : browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js => browser/devtools/inspector/test/browser_inspector_delete-selected-node-02.js
rename : browser/devtools/inspector/test/browser_inspector_destroyselection.js => browser/devtools/inspector/test/browser_inspector_delete-selected-node-03.js
rename : browser/devtools/inspector/test/browser_inspector_bug_840156_destroy_after_navigation.js => browser/devtools/inspector/test/browser_inspector_destroy-after`,
"Rename Inspector tests and supporting documents http://bugzil.la/988314",
},
[]string{
`Bug 1033387 - Update JSBeautify and move it into toolkit r=fitzgen
--HG--
rename : browser/devtools/shared/Jsbeautify.jsm => toolkit/devtools/jsbeautify/beautify.js`,
"Update JSBeautify and move it into toolkit http://bugzil.la/1033387",
},
[]string{
"Bug 1038651 - Prevent inspector from breaking when reloading an SVG file;r=mratcliffe",
"Prevent inspector from breaking when reloading an SVG file http://bugzil.la/1038651",
},
}
for _, duple := range messages {
if CreateMessage(duple[0], GetBugNumber(duple[0]), "") != duple[1] {
t.Error("Expected '" + CreateMessage(duple[0], GetBugNumber(duple[0]), "") + "' to equal '" + duple[1] + "'")
}
}
}
func TestGetBugNumber(t *testing.T) {
messages := [][]string{
[]string{
"Bug 1034670 - The canvas graphs should draw the background separately, r=pbrosset",
"1034670",
},
[]string{
"Bug 1034670 - The canvas graphs should draw the background separately, a=pbrosset",
"1034670",
},
[]string{
"Bug 1343: Support asm.js frames in SavedStacks. r=luke ",
"1343",
},
[]string{
" Bug 1034668-The `getMappedSelection` method for all canvas graphs should clamp the selection bounds, r=pbrosset,someoneelse, space",
"1034668",
},
[]string{
`Bug 988314 - Rename Inspector tests and supporting documents. r=pbrosset
--HG--
rename : browser/devtools/inspector/test/browser_inspector_bug_817558_delete_node.js => browser/devtools/inspector/test/browser_inspector_delete-selected-node-01.js
rename : browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js => browser/devtools/inspector/test/browser_inspector_delete-selected-node-02.js
rename : browser/devtools/inspector/test/browser_inspector_destroyselection.js => browser/devtools/inspector/test/browser_inspector_delete-selected-node-03.js
rename : browser/devtools/inspector/test/browser_inspector_bug_840156_destroy_after_navigation.js => browser/devtools/inspector/test/browser_inspector_destroy-after`,
"988314",
},
}
for _, duple := range messages {
if GetBugNumber(duple[0]) != duple[1] {
t.Error("Expected '" + duple[0] + "' to clean into '" + duple[1] + "'")
}
}
}
func TestGetBugzillaURL(t *testing.T) {
messages := [][]string{
[]string{
"1034670",
"http://bugzil.la/1034670",
},
[]string{
"1343",
"http://bugzil.la/1343",
},
[]string{
"",
"",
},
}
for _, duple := range messages {
if GetBugzillaURL(duple[0]) != duple[1] {
t.Error("Expected '" + duple[0] + "' to have a URL: " + duple[1])
}
}
}
func TestGetSubComponent(t *testing.T) {
messages := [][]string{
[]string{
"Developer Tools",
"",
},
[]string{
"Developer Tools: 3D View",
"Tilt",
},
[]string{
"Developer Tools: Inspector",
"Inspector",
},
[]string{
"Developer Tools: Web Audio Editor",
"Audio",
},
}
for _, duple := range messages {
if GetSubComponent(duple[0]) != duple[1] {
t.Error("Expected subcompobebt '" + duple[0] + "' to format to '" + duple[1])
}
}
}