Skip to content

Commit 755369d

Browse files
GiteaBotlunny
andauthored
Fix yaml test (go-gitea#27297) (go-gitea#27303)
Backport go-gitea#27297 by @lunny Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
1 parent 42f7c2a commit 755369d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

models/fixture_generation.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ func GetYamlFixturesAccess() (string, error) {
4040
fmt.Fprintf(&b, " user_id: %d\n", a.UserID)
4141
fmt.Fprintf(&b, " repo_id: %d\n", a.RepoID)
4242
fmt.Fprintf(&b, " mode: %d\n", a.Mode)
43-
fmt.Fprintf(&b, "\n")
43+
if i < len(accesses)-1 {
44+
fmt.Fprintf(&b, "\n")
45+
}
4446
}
4547

4648
return b.String(), nil

models/fixture_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ func TestFixtureGeneration(t *testing.T) {
2222
if !assert.NoError(t, err) {
2323
return
2424
}
25-
bytes, err := os.ReadFile(filepath.Join(unittest.FixturesDir(), name+".yml"))
25+
p := filepath.Join(unittest.FixturesDir(), name+".yml")
26+
bytes, err := os.ReadFile(p)
2627
if !assert.NoError(t, err) {
2728
return
2829
}
2930
data := string(util.NormalizeEOL(bytes))
30-
assert.True(t, data == expected, "Differences detected for %s.yml", name)
31+
assert.EqualValues(t, expected, data, "Differences detected for %s", p)
3132
}
3233

3334
test(GetYamlFixturesAccess, "access")

0 commit comments

Comments
 (0)