From 083c3ee659c6c5542687f3bafae68cbc24dbc90f Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Sat, 25 Jun 2022 18:07:39 +0800 Subject: db: refactor "action" table to use GORM (#7054) Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> --- internal/db/watches_test.go | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 internal/db/watches_test.go (limited to 'internal/db/watches_test.go') diff --git a/internal/db/watches_test.go b/internal/db/watches_test.go new file mode 100644 index 00000000..7ec5b93c --- /dev/null +++ b/internal/db/watches_test.go @@ -0,0 +1,47 @@ +// Copyright 2022 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package db + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "gogs.io/gogs/internal/dbtest" +) + +func TestWatches(t *testing.T) { + if testing.Short() { + t.Skip() + } + t.Parallel() + + tables := []interface{}{new(Watch)} + db := &watches{ + DB: dbtest.NewDB(t, "watches", tables...), + } + + for _, tc := range []struct { + name string + test func(*testing.T, *watches) + }{ + {"ListByRepo", watchesListByRepo}, + } { + t.Run(tc.name, func(t *testing.T) { + t.Cleanup(func() { + err := clearTables(t, db.DB, tables...) + require.NoError(t, err) + }) + tc.test(t, db) + }) + if t.Failed() { + break + } + } +} + +func watchesListByRepo(_ *testing.T, _ *watches) { + // TODO: Add tests once WatchRepo is migrated to GORM. +} -- cgit v1.2.3