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.

fixture_test.go 892B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package models
  4. import (
  5. "context"
  6. "os"
  7. "path/filepath"
  8. "testing"
  9. "code.gitea.io/gitea/models/db"
  10. "code.gitea.io/gitea/models/unittest"
  11. "code.gitea.io/gitea/modules/util"
  12. "github.com/stretchr/testify/assert"
  13. )
  14. func TestFixtureGeneration(t *testing.T) {
  15. assert.NoError(t, unittest.PrepareTestDatabase())
  16. test := func(ctx context.Context, gen func(ctx context.Context) (string, error), name string) {
  17. expected, err := gen(ctx)
  18. if !assert.NoError(t, err) {
  19. return
  20. }
  21. p := filepath.Join(unittest.FixturesDir(), name+".yml")
  22. bytes, err := os.ReadFile(p)
  23. if !assert.NoError(t, err) {
  24. return
  25. }
  26. data := string(util.NormalizeEOL(bytes))
  27. assert.EqualValues(t, expected, data, "Differences detected for %s", p)
  28. }
  29. test(db.DefaultContext, GetYamlFixturesAccess, "access")
  30. }