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.

v230_test.go 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_18 //nolint
  4. import (
  5. "testing"
  6. "code.gitea.io/gitea/models/migrations/base"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func Test_AddConfidentialClientColumnToOAuth2ApplicationTable(t *testing.T) {
  10. // premigration
  11. type oauth2Application struct {
  12. ID int64
  13. }
  14. // Prepare and load the testing database
  15. x, deferable := base.PrepareTestEnv(t, 0, new(oauth2Application))
  16. defer deferable()
  17. if x == nil || t.Failed() {
  18. return
  19. }
  20. if err := AddConfidentialClientColumnToOAuth2ApplicationTable(x); err != nil {
  21. assert.NoError(t, err)
  22. return
  23. }
  24. // postmigration
  25. type ExpectedOAuth2Application struct {
  26. ID int64
  27. ConfidentialClient bool
  28. }
  29. got := []ExpectedOAuth2Application{}
  30. if err := x.Table("oauth2_application").Select("id, confidential_client").Find(&got); !assert.NoError(t, err) {
  31. return
  32. }
  33. assert.NotEmpty(t, got)
  34. for _, e := range got {
  35. assert.True(t, e.ConfidentialClient)
  36. }
  37. }