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

Commit

Permalink
Fix the expires_at type
Browse files Browse the repository at this point in the history
  • Loading branch information
svanharmelen committed Nov 5, 2024
1 parent 0a4134b commit 75ad5f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
8 changes: 4 additions & 4 deletions deploy_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ func (s *DeployKeysService) GetDeployKey(pid interface{}, deployKey int, options
// GitLab API docs:
// https://docs.gitlab.com/ee/api/deploy_keys.html#add-deploy-key-for-a-project
type AddDeployKeyOptions struct {
Key *string `url:"key,omitempty" json:"key,omitempty"`
Title *string `url:"title,omitempty" json:"title,omitempty"`
CanPush *bool `url:"can_push,omitempty" json:"can_push,omitempty"`
ExpiresAt *ISOTime `url:"expires_at,omitempty" json:"expires_at,omitempty"`
Key *string `url:"key,omitempty" json:"key,omitempty"`
Title *string `url:"title,omitempty" json:"title,omitempty"`
CanPush *bool `url:"can_push,omitempty" json:"can_push,omitempty"`
ExpiresAt *time.Time `url:"expires_at,omitempty" json:"expires_at,omitempty"`
}

// AddDeployKey creates a new deploy key for a project. If deploy key already
Expand Down
14 changes: 6 additions & 8 deletions deploy_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,16 @@ func TestAddDeployKey_withExpiresAt(t *testing.T) {
}`)
})

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

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

createdAt, err := time.Parse(timeLayout, "2015-08-29T12:44:31.550Z")
if err != nil {
t.Errorf("DeployKeys.ListAllDeployKeys returned an error while parsing time: %v", err)
}

expiresAt, err := time.Parse(timeLayout, "2999-03-01T00:00:00.000Z")
if err != nil {
t.Errorf("DeployKeys.ListAllDeployKeys returned an error while parsing time: %v", err)
t.Errorf("DeployKeys.AddDeployKey returned an error while parsing time: %v", err)
}

want := &ProjectDeployKey{
Expand Down

0 comments on commit 75ad5f4

Please sign in to comment.