-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathparser_test.go
More file actions
42 lines (37 loc) · 1.11 KB
/
parser_test.go
File metadata and controls
42 lines (37 loc) · 1.11 KB
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
package local
import "testing"
func TestParseTags(t *testing.T) {
eSummary := "A Test"
eAuthor := "Dave Tucker <dt@docker.com> Rolf Neugebauer <rolf.neugebauer@docker.com>"
eLabels := "foo, bar, !baz"
eRepeat := 5
eIssue := "https://github.com/linuxkit/rtf/issues/1 https://github.com/linuxkit/rtf/issues/2"
tags, err := ParseTags("testdata/test.sh")
if err != nil {
t.Fatalf("Error parsing tags")
}
if eSummary != tags.Summary {
t.Fatalf("\nExpected: %s \nGot: %s\n", eSummary, tags.Summary)
}
if eAuthor != tags.Author {
t.Fatalf("\nExpected: %s \nGot: %s\n", eAuthor, tags.Author)
}
if eLabels != tags.Labels {
t.Fatalf("\nExpected: %s \nGot: %s\n", eLabels, tags.Labels)
}
if eRepeat != tags.Repeat {
t.Fatalf("\nExpected: %d \nGot: %d\n", eRepeat, tags.Repeat)
}
if eIssue != tags.Issue {
t.Fatalf("\nExpected: %s \nGot: %s\n", eIssue, tags.Issue)
}
}
func TestParseBadTags(t *testing.T) {
_, err := ParseTags("testdata/bad_test.sh")
if err == nil {
t.Fatalf("Should have caused an error")
}
if err.Error() != "field LABELS specified multiple times" {
t.Fatalf("Wrong error message")
}
}