[PR #796] [MERGED] Unit tests and remove unused functions in models/notification #15577

Closed
opened 2025-11-02 11:49:49 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/796
Author: @ethantkoenig
Created: 1/30/2017
Status: Merged
Merged: 1/30/2017
Merged by: @lunny

Base: masterHead: tests/notification


📝 Commits (2)

  • dc06d35 Unit tests and remove unused functions in models/notification
  • eb9ca2e Read -> Unread

📊 Changes

5 files changed (+108 additions, -11 deletions)

View changed files

models/fixtures/notification.yml (+21 -0)
models/fixtures/watch.yml (+9 -0)
📝 models/notification.go (+0 -10)
models/notification_test.go (+77 -0)
📝 routers/user/notification.go (+1 -1)

📄 Description

I removed the GetNotificationReadCount(..) and GetNotificationUnreadCount(..) functions for the following reasons:

  1. They were both just special cases of the more general GetNotificationCount(..) function.
  2. They were used sparingly (a total of once)
  3. IMO, having multiple ways to call a public functions like GetNotificationCount(..) (i.e. directly, or indirectly via GetNotificationXYZCount(..)) makes code more verbose and harder to test.

If anyone feels strongly that they should stay, I'll listen.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/796 **Author:** [@ethantkoenig](https://github.com/ethantkoenig) **Created:** 1/30/2017 **Status:** ✅ Merged **Merged:** 1/30/2017 **Merged by:** [@lunny](https://github.com/lunny) **Base:** `master` ← **Head:** `tests/notification` --- ### 📝 Commits (2) - [`dc06d35`](https://github.com/go-gitea/gitea/commit/dc06d3546854bf146153fda08edf1a9d22fb2b46) Unit tests and remove unused functions in models/notification - [`eb9ca2e`](https://github.com/go-gitea/gitea/commit/eb9ca2e29f717b4475f822b8db5e5f2153add3ed) Read -> Unread ### 📊 Changes **5 files changed** (+108 additions, -11 deletions) <details> <summary>View changed files</summary> ➕ `models/fixtures/notification.yml` (+21 -0) ➕ `models/fixtures/watch.yml` (+9 -0) 📝 `models/notification.go` (+0 -10) ➕ `models/notification_test.go` (+77 -0) 📝 `routers/user/notification.go` (+1 -1) </details> ### 📄 Description I removed the `GetNotificationReadCount(..)` and `GetNotificationUnreadCount(..)` functions for the following reasons: 1. They were both just special cases of the more general `GetNotificationCount(..)` function. 2. They were used sparingly (a total of once) 3. IMO, having multiple ways to call a public functions like `GetNotificationCount(..)` (i.e. directly, or indirectly via `GetNotificationXYZCount(..)`) makes code more verbose and harder to test. If anyone feels strongly that they should stay, I'll listen. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 11:49:49 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#15577