-
Notifications
You must be signed in to change notification settings - Fork 16
/
changelog_test.go
58 lines (49 loc) · 1.09 KB
/
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
50
51
52
53
54
55
56
57
58
package gopeer
import (
_ "embed"
"regexp"
"strings"
"testing"
"github.com/number571/go-peer/build"
)
var (
//go:embed CHANGELOG.md
tgCHANGELOG string
)
func TestGoPeerVersion(t *testing.T) {
t.Parallel()
re := regexp.MustCompile(`##\s+(v\d+\.\d+\.\d+~?)\s+`)
match := re.FindAllStringSubmatch(tgCHANGELOG, -1)
if len(match) < 2 {
t.Error("versions not found")
return
}
if strings.HasSuffix(build.CVersion, "~") {
if match[0][1] != build.CVersion {
t.Error("the versions do not match")
return
}
} else {
// current version is always previous version in the changelog
if match[1][1] != build.CVersion {
t.Error("the versions do not match")
return
}
}
if match[0][1] == match[1][1] {
t.Error("the same versions inline")
return
}
for i := 0; i < len(match); i++ {
for j := i + 1; j < len(match)-1; j++ {
if match[i][1] == match[j][1] {
t.Errorf("found the same versions (i=%d, j=%d)", i, j)
return
}
}
}
if strings.Count(tgCHANGELOG, "*??? ??, ????*") != 1 {
t.Error("is there no new version or more than one new version?")
return
}
}