summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-09-27 11:30:03 +0800
committerGitHub <noreply@github.com>2023-09-26 23:30:03 -0400
commite59c9e3ecdccac1262ed05d693fb826b03af9de8 (patch)
tree865e3b63bd03f674726e2e572dbe0be7517c904a /models
parentc5247eff73ea0be33affb97d666c9d222aabcc37 (diff)
downloadgitea-e59c9e3ecdccac1262ed05d693fb826b03af9de8.tar.gz
gitea-e59c9e3ecdccac1262ed05d693fb826b03af9de8.zip
Fix yaml test (#27297)
Diffstat (limited to 'models')
-rw-r--r--models/fixture_generation.go4
-rw-r--r--models/fixture_test.go5
2 files changed, 6 insertions, 3 deletions
diff --git a/models/fixture_generation.go b/models/fixture_generation.go
index abf880ee8e..d342919895 100644
--- a/models/fixture_generation.go
+++ b/models/fixture_generation.go
@@ -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
diff --git a/models/fixture_test.go b/models/fixture_test.go
index 8a28db8164..b70fdb536d 100644
--- a/models/fixture_test.go
+++ b/models/fixture_test.go
@@ -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")