2020-02-15 14:29:43 +05:30
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2020-02-15 14:29:43 +05:30
|
|
|
|
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
2021-09-22 11:08:34 +05:30
|
|
|
"os"
|
2020-02-15 14:29:43 +05:30
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2021-11-12 20:06:47 +05:30
|
|
|
"code.gitea.io/gitea/models/unittest"
|
2020-02-15 14:29:43 +05:30
|
|
|
"code.gitea.io/gitea/modules/util"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFixtureGeneration(t *testing.T) {
|
2021-11-12 20:06:47 +05:30
|
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
2020-02-15 14:29:43 +05:30
|
|
|
|
|
|
|
test := func(gen func() (string, error), name string) {
|
|
|
|
expected, err := gen()
|
|
|
|
if !assert.NoError(t, err) {
|
|
|
|
return
|
|
|
|
}
|
2023-09-27 09:00:03 +05:30
|
|
|
p := filepath.Join(unittest.FixturesDir(), name+".yml")
|
|
|
|
bytes, err := os.ReadFile(p)
|
2020-02-15 14:29:43 +05:30
|
|
|
if !assert.NoError(t, err) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
data := string(util.NormalizeEOL(bytes))
|
2023-09-27 09:00:03 +05:30
|
|
|
assert.EqualValues(t, expected, data, "Differences detected for %s", p)
|
2020-02-15 14:29:43 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
test(GetYamlFixturesAccess, "access")
|
|
|
|
}
|