Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Commit 75ad5f4

Browse files
committed
Fix the expires_at type
1 parent 0a4134b commit 75ad5f4

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

deploy_keys.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ func (s *DeployKeysService) GetDeployKey(pid interface{}, deployKey int, options
165165
// GitLab API docs:
166166
// https://docs.gitlab.com/ee/api/deploy_keys.html#add-deploy-key-for-a-project
167167
type AddDeployKeyOptions struct {
168-
Key *string `url:"key,omitempty" json:"key,omitempty"`
169-
Title *string `url:"title,omitempty" json:"title,omitempty"`
170-
CanPush *bool `url:"can_push,omitempty" json:"can_push,omitempty"`
171-
ExpiresAt *ISOTime `url:"expires_at,omitempty" json:"expires_at,omitempty"`
168+
Key *string `url:"key,omitempty" json:"key,omitempty"`
169+
Title *string `url:"title,omitempty" json:"title,omitempty"`
170+
CanPush *bool `url:"can_push,omitempty" json:"can_push,omitempty"`
171+
ExpiresAt *time.Time `url:"expires_at,omitempty" json:"expires_at,omitempty"`
172172
}
173173

174174
// AddDeployKey creates a new deploy key for a project. If deploy key already

deploy_keys_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,16 @@ func TestAddDeployKey_withExpiresAt(t *testing.T) {
272272
}`)
273273
})
274274

275-
expiresAtIsoTime := ISOTime(time.Date(2999, time.March, 1, 0, 0, 0, 0, time.UTC))
275+
expiresAt, err := time.Parse(timeLayout, "2999-03-01T00:00:00.000Z")
276+
if err != nil {
277+
t.Errorf("DeployKeys.AddDeployKey returned an error while parsing time: %v", err)
278+
}
276279

277280
opt := &AddDeployKeyOptions{
278281
Key: Ptr("ssh-rsa AAAA..."),
279282
Title: Ptr("My deploy key"),
280283
CanPush: Ptr(true),
281-
ExpiresAt: &expiresAtIsoTime,
284+
ExpiresAt: &expiresAt,
282285
}
283286
deployKey, _, err := client.DeployKeys.AddDeployKey(5, opt)
284287
if err != nil {
@@ -287,12 +290,7 @@ func TestAddDeployKey_withExpiresAt(t *testing.T) {
287290

288291
createdAt, err := time.Parse(timeLayout, "2015-08-29T12:44:31.550Z")
289292
if err != nil {
290-
t.Errorf("DeployKeys.ListAllDeployKeys returned an error while parsing time: %v", err)
291-
}
292-
293-
expiresAt, err := time.Parse(timeLayout, "2999-03-01T00:00:00.000Z")
294-
if err != nil {
295-
t.Errorf("DeployKeys.ListAllDeployKeys returned an error while parsing time: %v", err)
293+
t.Errorf("DeployKeys.AddDeployKey returned an error while parsing time: %v", err)
296294
}
297295

298296
want := &ProjectDeployKey{

0 commit comments

Comments
 (0)