watches_test.go 894 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2022 The Gogs 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 db
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/require"
  8. "gogs.io/gogs/internal/dbtest"
  9. )
  10. func TestWatches(t *testing.T) {
  11. if testing.Short() {
  12. t.Skip()
  13. }
  14. t.Parallel()
  15. tables := []interface{}{new(Watch)}
  16. db := &watches{
  17. DB: dbtest.NewDB(t, "watches", tables...),
  18. }
  19. for _, tc := range []struct {
  20. name string
  21. test func(t *testing.T, db *watches)
  22. }{
  23. {"ListByRepo", watchesListByRepo},
  24. } {
  25. t.Run(tc.name, func(t *testing.T) {
  26. t.Cleanup(func() {
  27. err := clearTables(t, db.DB, tables...)
  28. require.NoError(t, err)
  29. })
  30. tc.test(t, db)
  31. })
  32. if t.Failed() {
  33. break
  34. }
  35. }
  36. }
  37. func watchesListByRepo(_ *testing.T, _ *watches) {
  38. // TODO: Add tests once WatchRepo is migrated to GORM.
  39. }