2
0
Files
logikonline 12f4ea03a8
Some checks failed
Build and Release / Create Release (push) Successful in 0s
Trigger Vault Plugin Rebuild / Trigger Vault Rebuild (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m48s
Build and Release / Lint (push) Failing after 5m2s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, darwin, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (arm64, linux, linux-latest) (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 5m37s
refactor: add /v3 suffix to module path for proper Go semver
Go's semantic import versioning requires v2+ modules to include the
major version in the module path. This enables using proper version
tags (v3.x.x) instead of pseudo-versions.

Updated module path: code.gitcaddy.com/server/v3
2026-01-17 17:53:59 -05:00

68 lines
2.0 KiB
Go

// Copyright 2017 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package issues_test
import (
"testing"
"code.gitcaddy.com/server/v3/models/db"
issues_model "code.gitcaddy.com/server/v3/models/issues"
"code.gitcaddy.com/server/v3/models/unittest"
"github.com/stretchr/testify/assert"
)
func TestCreateOrUpdateIssueWatch(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
assert.NoError(t, issues_model.CreateOrUpdateIssueWatch(t.Context(), 3, 1, true))
iw := unittest.AssertExistsAndLoadBean(t, &issues_model.IssueWatch{UserID: 3, IssueID: 1})
assert.True(t, iw.IsWatching)
assert.NoError(t, issues_model.CreateOrUpdateIssueWatch(t.Context(), 1, 1, false))
iw = unittest.AssertExistsAndLoadBean(t, &issues_model.IssueWatch{UserID: 1, IssueID: 1})
assert.False(t, iw.IsWatching)
}
func TestGetIssueWatch(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
_, exists, err := issues_model.GetIssueWatch(t.Context(), 9, 1)
assert.True(t, exists)
assert.NoError(t, err)
iw, exists, err := issues_model.GetIssueWatch(t.Context(), 2, 2)
assert.True(t, exists)
assert.NoError(t, err)
assert.False(t, iw.IsWatching)
_, exists, err = issues_model.GetIssueWatch(t.Context(), 3, 1)
assert.False(t, exists)
assert.NoError(t, err)
}
func TestGetIssueWatchers(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
iws, err := issues_model.GetIssueWatchers(t.Context(), 1, db.ListOptions{})
assert.NoError(t, err)
// Watcher is inactive, thus 0
assert.Empty(t, iws)
iws, err = issues_model.GetIssueWatchers(t.Context(), 2, db.ListOptions{})
assert.NoError(t, err)
// Watcher is explicit not watching
assert.Empty(t, iws)
iws, err = issues_model.GetIssueWatchers(t.Context(), 5, db.ListOptions{})
assert.NoError(t, err)
// Issue has no Watchers
assert.Empty(t, iws)
iws, err = issues_model.GetIssueWatchers(t.Context(), 7, db.ListOptions{})
assert.NoError(t, err)
// Issue has one watcher
assert.Len(t, iws, 1)
}