77 "log"
88 "os"
99 "os/exec"
10+ "path/filepath"
1011 "strings"
1112 "testing"
1213
@@ -125,16 +126,16 @@ func TestChangelog(t *testing.T) {
125126
126127func checkChangelogFilesAreTheSame (t * testing.T , cmdOutput , testOutput string ) {
127128 t .Helper ()
128- log .Printf ("Checking file: %s" , fmt . Sprintf ( "%s/%s" , cmdOutput , "changelog.json" ))
129- cmdChangelog := newEntriesFromPath (t , fmt . Sprintf ( "%s/%s" , cmdOutput , "changelog.json" ))
129+ fmt .Printf ("Checking file: %s" , filepath . Join ( cmdOutput , "changelog.json" ))
130+ cmdChangelog := newEntriesFromPath (t , filepath . Join ( cmdOutput , "changelog.json" ))
130131
131- log .Printf ("With test file: %s" , fmt . Sprintf ( "%s/%s" , testOutput , "changelog.json" ))
132- testChangelog := newEntriesFromPath (t , fmt . Sprintf ( "%s/%s" , testOutput , "changelog.json" ))
132+ fmt .Printf ("With test file: %s" , filepath . Join ( testOutput , "changelog.json" ))
133+ testChangelog := newEntriesFromPath (t , filepath . Join ( testOutput , "changelog.json" ))
133134 areEntriesTheSame (t , cmdChangelog , testChangelog )
134135
135136 log .Print ("Checking file: changelog-all.json" )
136- cmdChangelogAll := newEntriesFromPath (t , fmt . Sprintf ( "%s/%s" , cmdOutput , "internal/ changelog-all.json" ))
137- testChangelogAll := newEntriesFromPath (t , fmt . Sprintf ( "%s/%s" , testOutput , "changelog-all.json" ))
137+ cmdChangelogAll := newEntriesFromPath (t , filepath . Join ( cmdOutput , "internal" , " changelog-all.json" ))
138+ testChangelogAll := newEntriesFromPath (t , filepath . Join ( testOutput , "changelog-all.json" ))
138139 areEntriesTheSame (t , cmdChangelogAll , testChangelogAll )
139140 compareVersions (t , cmdOutput , testOutput )
140141}
@@ -146,7 +147,7 @@ func compareVersions(t *testing.T, cmdOutput, testOutput string) {
146147 require .NoError (t , err )
147148
148149 // Compare number of version-diff files
149- cmdFiles , err := os .ReadDir (fmt . Sprintf ( "%s/%s" , cmdOutput , "version-diff" ))
150+ cmdFiles , err := os .ReadDir (filepath . Join ( cmdOutput , "version-diff" ))
150151 require .NoError (t , err )
151152 // Ignore the changelog.json and changelog-all.json files
152153 require .Len (t , cmdFiles , len (files )- 2 )
@@ -161,9 +162,9 @@ func compareVersions(t *testing.T, cmdOutput, testOutput string) {
161162 continue
162163 }
163164
164- log .Printf ("Checking file: %s" , fileName .Name ())
165- cmdPaths := newPathsFromPath (t , fmt . Sprintf ( "%s/%s/%s" , cmdOutput , "version-diff" , fileName .Name ()))
166- testPaths := newPathsFromPath (t , fmt . Sprintf ( "%s/%s" , testOutput , fileName .Name ()))
165+ fmt .Printf ("Checking file: %s" , fileName .Name ())
166+ cmdPaths := newPathsFromPath (t , filepath . Join ( cmdOutput , "version-diff" , fileName .Name ()))
167+ testPaths := newPathsFromPath (t , filepath . Join ( testOutput , fileName .Name ()))
167168 arePathsTheSame (t , cmdPaths , testPaths )
168169 }
169170}
0 commit comments