github.com/avenga/couper@v1.12.2/changelog_test.go (about) 1 package main 2 3 import ( 4 "bufio" 5 "bytes" 6 "io" 7 "os" 8 "regexp" 9 "testing" 10 11 "github.com/avenga/couper/internal/test" 12 ) 13 14 // TestChangelog_Links ensures that every added/changed/fixed listing has a link (pr/issue). 15 func TestChangelog_Links(t *testing.T) { 16 helper := test.New(t) 17 18 changelog, err := os.Open("CHANGELOG.md") 19 helper.Must(err) 20 defer changelog.Close() 21 22 r := bufio.NewReader(changelog) 23 24 linkRegex := regexp.MustCompile(`\(\[#\d+]\(.+/(pull|issues)/\d+\)\)\n$`) 25 26 nr := 0 27 for { 28 nr++ 29 line, readErr := r.ReadSlice('\n') 30 if readErr == io.EOF { 31 return 32 } 33 helper.Must(readErr) 34 35 // Link Condition introduced with 1.2 release. 36 if bytes.Equal(line, []byte("Release date: 2021-04-21\n")) { 37 return 38 } 39 40 if !bytes.HasPrefix(line, []byte(" * ")) { 41 continue 42 } 43 44 if !linkRegex.Match(line) { 45 t.Errorf("line %d: missing issue or pull-request link:\n\t%q", nr, string(line)) 46 } 47 } 48 }