gitea源码

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2025 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_23
  4. import (
  5. "testing"
  6. "code.gitea.io/gitea/models/migrations/base"
  7. "code.gitea.io/gitea/modules/timeutil"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func Test_AddIndexForReleaseSha1(t *testing.T) {
  11. type Release struct {
  12. ID int64 `xorm:"pk autoincr"`
  13. RepoID int64 `xorm:"INDEX UNIQUE(n)"`
  14. PublisherID int64 `xorm:"INDEX"`
  15. TagName string `xorm:"INDEX UNIQUE(n)"`
  16. OriginalAuthor string
  17. OriginalAuthorID int64 `xorm:"index"`
  18. LowerTagName string
  19. Target string
  20. Title string
  21. Sha1 string `xorm:"VARCHAR(64)"`
  22. NumCommits int64
  23. Note string `xorm:"TEXT"`
  24. IsDraft bool `xorm:"NOT NULL DEFAULT false"`
  25. IsPrerelease bool `xorm:"NOT NULL DEFAULT false"`
  26. IsTag bool `xorm:"NOT NULL DEFAULT false"` // will be true only if the record is a tag and has no related releases
  27. CreatedUnix timeutil.TimeStamp `xorm:"INDEX"`
  28. }
  29. // Prepare and load the testing database
  30. x, deferable := base.PrepareTestEnv(t, 0, new(Release))
  31. defer deferable()
  32. assert.NoError(t, AddIndexForReleaseSha1(x))
  33. }