Skip to content

Commit

Permalink
Fix yaml test (#27297) (#27303)
Browse files Browse the repository at this point in the history
Backport #27297 by @lunny

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
  • Loading branch information
GiteaBot and lunny committed Sep 27, 2023
1 parent 42f7c2a commit 755369d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion models/fixture_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func GetYamlFixturesAccess() (string, error) {
fmt.Fprintf(&b, " user_id: %d\n", a.UserID)
fmt.Fprintf(&b, " repo_id: %d\n", a.RepoID)
fmt.Fprintf(&b, " mode: %d\n", a.Mode)
fmt.Fprintf(&b, "\n")
if i < len(accesses)-1 {
fmt.Fprintf(&b, "\n")
}
}

return b.String(), nil
Expand Down
5 changes: 3 additions & 2 deletions models/fixture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ func TestFixtureGeneration(t *testing.T) {
if !assert.NoError(t, err) {
return
}
bytes, err := os.ReadFile(filepath.Join(unittest.FixturesDir(), name+".yml"))
p := filepath.Join(unittest.FixturesDir(), name+".yml")
bytes, err := os.ReadFile(p)
if !assert.NoError(t, err) {
return
}
data := string(util.NormalizeEOL(bytes))
assert.True(t, data == expected, "Differences detected for %s.yml", name)
assert.EqualValues(t, expected, data, "Differences detected for %s", p)
}

test(GetYamlFixturesAccess, "access")
Expand Down

0 comments on commit 755369d

Please sign in to comment.