forked from coupergateway/couper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangelog_test.go
49 lines (38 loc) · 912 Bytes
/
changelog_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
package main
import (
"bufio"
"bytes"
"io"
"os"
"regexp"
"testing"
"github.com/avenga/couper/internal/test"
)
// TestChangelog_Links ensures that every added/changed/fixed listing has a link (pr/issue).
func TestChangelog_Links(t *testing.T) {
helper := test.New(t)
changelog, err := os.Open("CHANGELOG.md")
helper.Must(err)
defer changelog.Close()
r := bufio.NewReader(changelog)
linkRegex := regexp.MustCompile(`\(\[#\d+]\(.+/(pull|issues)/\d+\)\)\n$`)
nr := 0
for {
nr++
line, readErr := r.ReadSlice('\n')
if readErr == io.EOF {
return
}
helper.Must(readErr)
// Link Condition introduced with 1.2 release.
if bytes.Equal(line, []byte("Release date: 2021-04-21\n")) {
return
}
if !bytes.HasPrefix(line, []byte(" * ")) {
continue
}
if !linkRegex.Match(line) {
t.Errorf("line %d: missing issue or pull-request link:\n\t%q", nr, string(line))
}
}
}