You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
803 B

  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. "io/ioutil"
  7. "path/filepath"
  8. "testing"
  9. "code.gitea.io/gitea/modules/util"
  10. "github.com/stretchr/testify/assert"
  11. )
  12. func TestFixtureGeneration(t *testing.T) {
  13. assert.NoError(t, PrepareTestDatabase())
  14. test := func(gen func() (string, error), name string) {
  15. expected, err := gen()
  16. if !assert.NoError(t, err) {
  17. return
  18. }
  19. bytes, err := ioutil.ReadFile(filepath.Join(fixturesDir, name+".yml"))
  20. if !assert.NoError(t, err) {
  21. return
  22. }
  23. data := string(util.NormalizeEOL(bytes))
  24. assert.True(t, data == expected, "Differences detected for %s.yml", name)
  25. }
  26. test(GetYamlFixturesAccess, "access")
  27. }