Introduce NotifySubjectState #520
|
@ -29,11 +29,11 @@ type NotificationThread struct {
|
|||
|
||||
// NotificationSubject contains the notification subject (Issue/Pull/Commit)
|
||||
type NotificationSubject struct {
|
||||
Title string `json:"title"`
|
||||
URL string `json:"url"`
|
||||
LatestCommentURL string `json:"latest_comment_url"`
|
||||
Type string `json:"type"`
|
||||
State StateType `json:"state"`
|
||||
Title string `json:"title"`
|
||||
URL string `json:"url"`
|
||||
LatestCommentURL string `json:"latest_comment_url"`
|
||||
Type string `json:"type"`
|
||||
State NotifySubjectState `json:"state"`
|
||||
}
|
||||
|
||||
// NotifyStatus notification status type
|
||||
|
@ -48,6 +48,18 @@ const (
|
|||
NotifyStatusPinned NotifyStatus = "pinned"
|
||||
)
|
||||
|
||||
// NotifySubjectState reflect state of notification subject
|
||||
type NotifySubjectState string
|
||||
|
||||
const (
|
||||
// NotifySubjectOpen if subject is a pull/issue and is open at the moment
|
||||
NotifySubjectOpen NotifySubjectState = "open"
|
||||
// NotifySubjectClosed if subject is a pull/issue and is closed at the moment
|
||||
NotifySubjectClosed NotifySubjectState = "closed"
|
||||
// NotifySubjectMerged if subject is a pull and got merged
|
||||
NotifySubjectMerged NotifySubjectState = "merged"
|
||||
)
|
||||
|
||||
// ListNotificationOptions represents the filter options
|
||||
type ListNotificationOptions struct {
|
||||
ListOptions
|
||||
|
|
|
@ -60,6 +60,8 @@ func TestNotifications(t *testing.T) {
|
|||
for _, n := range nList {
|
||||
assert.EqualValues(t, true, n.Unread)
|
||||
assert.EqualValues(t, "Issue", n.Subject.Type)
|
||||
assert.EqualValues(t, NotifySubjectOpen, nList[0].Subject.State)
|
||||
assert.EqualValues(t, NotifySubjectOpen, nList[1].Subject.State)
|
||||
if n.Subject.Title == "A Issue" {
|
||||
assert.EqualValues(t, repoA.Name, n.Repository.Name)
|
||||
} else if n.Subject.Title == "B Issue" {
|
||||
|
@ -104,8 +106,8 @@ func TestNotifications(t *testing.T) {
|
|||
count, _, err = c.CheckNotifications()
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, count)
|
||||
assert.Len(t, nList, 1)
|
||||
if len(nList) > 0 {
|
||||
if assert.Len(t, nList, 1) {
|
||||
assert.EqualValues(t, NotifySubjectClosed, nList[0].Subject.State)
|
||||
_, err = c.ReadNotification(nList[0].ID)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
@ -124,5 +126,8 @@ func TestNotifications(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
nList, _, err = c.ListNotifications(ListNotificationOptions{Status: []NotifyStatus{NotifyStatusPinned, NotifyStatusUnread}})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, nList, 2)
|
||||
if assert.Len(t, nList, 2) {
|
||||
assert.EqualValues(t, NotifySubjectClosed, nList[0].Subject.State)
|
||||
assert.EqualValues(t, NotifySubjectClosed, nList[1].Subject.State)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user