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.

engine_test.go 833B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2019 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/db"
  10. "code.gitea.io/gitea/models/unittest"
  11. "code.gitea.io/gitea/modules/setting"
  12. "github.com/stretchr/testify/assert"
  13. )
  14. func TestDumpDatabase(t *testing.T) {
  15. assert.NoError(t, unittest.PrepareTestDatabase())
  16. dir, err := os.MkdirTemp(os.TempDir(), "dump")
  17. assert.NoError(t, err)
  18. type Version struct {
  19. ID int64 `xorm:"pk autoincr"`
  20. Version int64
  21. }
  22. assert.NoError(t, db.GetEngine(db.DefaultContext).Sync2(new(Version)))
  23. for _, dbType := range setting.SupportedDatabaseTypes {
  24. assert.NoError(t, db.DumpDatabase(filepath.Join(dir, dbType+".sql"), dbType))
  25. }
  26. }