2020-02-15 08:59:43 +00:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
2021-09-22 05:38:34 +00:00
|
|
|
"os"
|
2020-02-15 08:59:43 +00:00
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2021-09-19 11:49:59 +00:00
|
|
|
"code.gitea.io/gitea/models/db"
|
2020-02-15 08:59:43 +00:00
|
|
|
"code.gitea.io/gitea/modules/util"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFixtureGeneration(t *testing.T) {
|
2021-09-19 11:49:59 +00:00
|
|
|
assert.NoError(t, db.PrepareTestDatabase())
|
2020-02-15 08:59:43 +00:00
|
|
|
|
|
|
|
test := func(gen func() (string, error), name string) {
|
|
|
|
expected, err := gen()
|
|
|
|
if !assert.NoError(t, err) {
|
|
|
|
return
|
|
|
|
}
|
2021-09-22 05:38:34 +00:00
|
|
|
bytes, err := os.ReadFile(filepath.Join(db.FixturesDir(), name+".yml"))
|
2020-02-15 08:59:43 +00:00
|
|
|
if !assert.NoError(t, err) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
data := string(util.NormalizeEOL(bytes))
|
|
|
|
assert.True(t, data == expected, "Differences detected for %s.yml", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
test(GetYamlFixturesAccess, "access")
|
|
|
|
}
|