Skip to content

Commit 3325868

Browse files
authored
Use zero value by default for comments edited time when simulating PR status (#978)
1 parent 71113bd commit 3325868

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

policy/simulated/options.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ type Comment struct {
7272
Body string `json:"body"`
7373
}
7474

75-
// setDefaults sets the createdAt and lastEdtedAt values to time.Now() if they are otherwise unset
75+
// setDefaults sets the createdAt value to time.Now(), and the lastEditedAt value to zero, if they are otherwise unset
7676
func (c *Comment) setDefaults() {
7777
now := time.Now()
7878
if c.CreatedAt == nil {
7979
c.CreatedAt = &now
8080
}
8181

8282
if c.LastEditedAt == nil {
83-
c.LastEditedAt = &now
83+
c.LastEditedAt = &time.Time{}
8484
}
8585
}
8686

@@ -112,7 +112,7 @@ func (r *Review) setDefaults(id, sha string) {
112112
}
113113

114114
if r.LastEditedAt == nil {
115-
r.LastEditedAt = &now
115+
r.LastEditedAt = &time.Time{}
116116
}
117117

118118
r.ID = id

policy/simulated/options_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ func TestOptionDefaults(t *testing.T) {
8282
options.setDefaults()
8383
for _, comment := range options.AddComments {
8484
assert.False(t, comment.CreatedAt.IsZero())
85-
assert.False(t, comment.LastEditedAt.IsZero())
85+
assert.True(t, comment.LastEditedAt.IsZero())
8686
}
8787

8888
for _, review := range options.AddReviews {
8989
assert.False(t, review.CreatedAt.IsZero())
90-
assert.False(t, review.LastEditedAt.IsZero())
90+
assert.True(t, review.LastEditedAt.IsZero())
9191
}
9292
}

0 commit comments

Comments
 (0)