@@ -184,50 +184,49 @@ func (TestScopeConfig) TableName() string {
184
184
func TestSetScopeFields (t * testing.T ) {
185
185
// create a struct
186
186
type P struct {
187
- ConnectionId uint64 `json:"connectionId" mapstructure:"connectionId" gorm:"primaryKey"`
188
- GitlabId int `json:"gitlabId" mapstructure:"gitlabId" gorm:"primaryKey"`
189
-
190
- CreatedDate * time.Time `json:"createdDate" mapstructure:"-"`
191
- UpdatedDate * time.Time `json:"updatedDate" mapstructure:"-"`
187
+ ConnectionId uint64 `json:"connectionId" mapstructure:"connectionId" gorm:"primaryKey"`
188
+ GitlabId int `json:"gitlabId" mapstructure:"gitlabId" gorm:"primaryKey"`
189
+ CreatedAt * time.Time `json:"createdAt" mapstructure:"-"`
190
+ UpdatedAt * time.Time `json:"updatedAt" mapstructure:"-"`
192
191
common.NoPKModel `json:"-" mapstructure:"-"`
193
192
}
194
193
p := P {}
195
194
apiHelper := createMockScopeHelper [TestFakeGitlabRepo ]("GitlabId" )
196
195
197
196
// call setScopeFields to assign value
198
197
connectionId := uint64 (123 )
199
- createdDate := time .Now ()
200
- updatedDate := & createdDate
201
- apiHelper .setScopeFields (& p , connectionId , & createdDate , updatedDate )
198
+ createdAt := time .Now ()
199
+ updatedAt := & createdAt
200
+ apiHelper .setScopeFields (& p , connectionId , & createdAt , updatedAt )
202
201
203
202
// verify fields
204
203
if p .ConnectionId != connectionId {
205
204
t .Errorf ("ConnectionId not set correctly, expected: %v, got: %v" , connectionId , p .ConnectionId )
206
205
}
207
206
208
- if ! p .CreatedDate .Equal (createdDate ) {
209
- t .Errorf ("CreatedDate not set correctly, expected: %v, got: %v" , createdDate , p .CreatedDate )
207
+ if ! p .CreatedAt .Equal (createdAt ) {
208
+ t .Errorf ("CreatedAt not set correctly, expected: %v, got: %v" , createdAt , p .CreatedAt )
210
209
}
211
210
212
- if p .UpdatedDate == nil {
213
- t .Errorf ("UpdatedDate not set correctly, expected: %v, got: %v" , updatedDate , p .UpdatedDate )
214
- } else if ! p .UpdatedDate .Equal (* updatedDate ) {
215
- t .Errorf ("UpdatedDate not set correctly, expected: %v, got: %v" , updatedDate , p .UpdatedDate )
211
+ if p .UpdatedAt == nil {
212
+ t .Errorf ("UpdatedDate not set correctly, expected: %v, got: %v" , updatedAt , p .UpdatedAt )
213
+ } else if ! p .UpdatedAt .Equal (* updatedAt ) {
214
+ t .Errorf ("UpdatedDate not set correctly, expected: %v, got: %v" , updatedAt , p .UpdatedAt )
216
215
}
217
216
218
- apiHelper .setScopeFields (& p , connectionId , & createdDate , nil )
217
+ apiHelper .setScopeFields (& p , connectionId , & createdAt , nil )
219
218
220
219
// verify fields
221
220
if p .ConnectionId != connectionId {
222
221
t .Errorf ("ConnectionId not set correctly, expected: %v, got: %v" , connectionId , p .ConnectionId )
223
222
}
224
223
225
- if ! p .CreatedDate .Equal (createdDate ) {
226
- t .Errorf ("CreatedDate not set correctly, expected: %v, got: %v" , createdDate , p .CreatedDate )
224
+ if ! p .CreatedAt .Equal (createdAt ) {
225
+ t .Errorf ("CreatedDate not set correctly, expected: %v, got: %v" , createdAt , p .CreatedAt )
227
226
}
228
227
229
- if p .UpdatedDate != nil {
230
- t .Errorf ("UpdatedDate not set correctly, expected: %v, got: %v" , nil , p .UpdatedDate )
228
+ if p .UpdatedAt != nil {
229
+ t .Errorf ("UpdatedDate not set correctly, expected: %v, got: %v" , nil , p .UpdatedAt )
231
230
}
232
231
}
233
232
0 commit comments