pupate

Puzzle transpiler
git clone https://git.woozle.org/neale/pupate.git

pupate / pkg / changelog
Neale Pickett  ·  2024-12-20

changelog_test.go

 1package changelog
 2
 3import (
 4	"testing"
 5	"testing/fstest"
 6)
 7
 8var noChangelogFS = fstest.MapFS{}
 9
10var badChangelogFS = fstest.MapFS{
11	"CHANGELOG.md": &fstest.MapFile{
12		Data: []byte("bloop"),
13	},
14}
15
16var badSyntaxChangelogFS = fstest.MapFS{
17	"CHANGELOG.md": &fstest.MapFile{
18		Data: []byte(`A changelog!
19## 1.0.0 - unreleased
20`),
21	},
22}
23
24var unreleasedChangelogFS = fstest.MapFS{
25	"CHANGELOG.md": &fstest.MapFile{
26		Data: []byte(`A changelog!
27## [unreleased]
28- bloop
29`),
30	},
31}
32
33var releasedChangelogFS = fstest.MapFS{
34	"CHANGELOG.md": &fstest.MapFile{
35		Data: []byte(`A changelog!
36## [1.0.0] - 2017-06-20
37- bloop
38
39## [0.9.0] - 2017-06-19
40- bloop
41`),
42	},
43}
44
45func TestNoChangelog(t *testing.T) {
46	v, d := ReadVersionFS(noChangelogFS)
47	if (v != "unknown-nochangelog") || (d != "???") {
48		t.Fatal("Wrong version:", v, d)
49	}
50}
51
52func TestBadChangelog(t *testing.T) {
53	v, d := ReadVersionFS(badChangelogFS)
54	if (v != "unknown-changelog-noversion") || (d != "???") {
55		t.Fatal("Wrong version:", v, d)
56	}
57}
58
59func TestBadSyntaxChangelog(t *testing.T) {
60	v, d := ReadVersionFS(badSyntaxChangelogFS)
61	if (v != "unknown-changelog-noversion") || (d != "???") {
62		t.Fatal("Wrong version:", v, d)
63	}
64}
65
66func TestUnreleasedChangelog(t *testing.T) {
67	v, d := ReadVersionFS(unreleasedChangelogFS)
68	if (v != "unreleased") || (d != "???") {
69		t.Fatal("Wrong version:", v, d)
70	}
71}
72
73func TestReleasedChangelog(t *testing.T) {
74	v, d := ReadVersionFS(releasedChangelogFS)
75	if (v != "1.0.0") || (d != "2017-06-20") {
76		t.Fatal("Wrong version:", v, d)
77	}
78}
79