您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

fixture_test.go 851B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package models
  5. import (
  6. "os"
  7. "path/filepath"
  8. "testing"
  9. "code.gitea.io/gitea/models/unittest"
  10. "code.gitea.io/gitea/modules/util"
  11. "github.com/stretchr/testify/assert"
  12. )
  13. func TestFixtureGeneration(t *testing.T) {
  14. assert.NoError(t, unittest.PrepareTestDatabase())
  15. test := func(gen func() (string, error), name string) {
  16. expected, err := gen()
  17. if !assert.NoError(t, err) {
  18. return
  19. }
  20. bytes, err := os.ReadFile(filepath.Join(unittest.FixturesDir(), name+".yml"))
  21. if !assert.NoError(t, err) {
  22. return
  23. }
  24. data := string(util.NormalizeEOL(bytes))
  25. assert.True(t, data == expected, "Differences detected for %s.yml", name)
  26. }
  27. test(GetYamlFixturesAccess, "access")
  28. }