Skip to content

Commit

Permalink
Final few tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
svanharmelen committed May 31, 2023
1 parent d59139c commit cad3179
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 47 deletions.
7 changes: 5 additions & 2 deletions protected_environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ type ProtectedEnvironment struct {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html
type EnvironmentAccessDescription struct {
ID int `json:"id"`
AccessLevel AccessLevelValue `json:"access_level"`
AccessLevelDescription string `json:"access_level_description"`
UserID int `json:"user_id"`
GroupID int `json:"group_id"`
}

// EnvironmentApprovalRule represents the approval rules for a protected environment.
// EnvironmentApprovalRule represents the approval rules for a protected
// environment.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html#protect-a-single-environment
Expand Down Expand Up @@ -149,7 +151,8 @@ type EnvironmentAccessOptions struct {
GroupID *int `url:"group_id,omitempty" json:"group_id,omitempty"`
}

// EnvironmentApprovalRuleOptions represents the approval rules for a protected environment.
// EnvironmentApprovalRuleOptions represents the approval rules for a protected
// environment.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_environments.html#protect-a-single-environment
Expand Down
88 changes: 43 additions & 45 deletions protected_environments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@ func TestListProtectedEnvironments(t *testing.T) {
}
],
"required_approval_count": 1,
"approval_rules": [
{
"id": 38,
"user_id": 42,
"group_id": null,
"access_level": null,
"access_level_description": "qa-group",
"required_approvals": 1,
"group_inheritance_type": 0
},
{
"id": 39,
"user_id": null,
"group_id": 135,
"access_level": 30,
"access_level_description": "security-group",
"required_approvals": 2,
"group_inheritance_type": 1
}
]
"approval_rules": [
{
"id": 38,
"user_id": 42,
"group_id": null,
"access_level": null,
"access_level_description": "qa-group",
"required_approvals": 1,
"group_inheritance_type": 0
},
{
"id": 39,
"user_id": null,
"group_id": 135,
"access_level": 30,
"access_level_description": "security-group",
"required_approvals": 2,
"group_inheritance_type": 1
}
]
},{
"name":"*-release",
"deploy_access_levels": [
Expand Down Expand Up @@ -130,17 +130,17 @@ func TestGetProtectedEnvironment(t *testing.T) {
}
],
"required_approval_count": 1,
"approval_rules": [
{
"id": 1,
"user_id": null,
"group_id": 10,
"access_level": 5,
"access_level_description": "devops",
"required_approvals": 0,
"group_inheritance_type": 0
}
]
"approval_rules": [
{
"id": 1,
"user_id": null,
"group_id": 10,
"access_level": 5,
"access_level_description": "devops",
"required_approvals": 0,
"group_inheritance_type": 0
}
]
}`)
})

Expand Down Expand Up @@ -213,17 +213,17 @@ func TestProtectRepositoryEnvironments(t *testing.T) {
}
],
"required_approval_count": 2,
"approval_rules": [
{
"id": 1,
"user_id": null,
"group_id": 10,
"access_level": 5,
"access_level_description": "devops",
"required_approvals": 0,
"group_inheritance_type": 0
}
]
"approval_rules": [
{
"id": 1,
"user_id": null,
"group_id": 10,
"access_level": 5,
"access_level_description": "devops",
"required_approvals": 0,
"group_inheritance_type": 0
}
]
}`)
})

Expand All @@ -246,8 +246,6 @@ func TestProtectRepositoryEnvironments(t *testing.T) {
},
}

noPermissions := NoPermissions

opt := &ProtectRepositoryEnvironmentsOptions{
Name: String("my-awesome-environment"),
DeployAccessLevels: &[]*EnvironmentAccessOptions{
Expand All @@ -257,7 +255,7 @@ func TestProtectRepositoryEnvironments(t *testing.T) {
ApprovalRules: &[]*EnvironmentApprovalRuleOptions{
{
GroupID: Int(10),
AccessLevel: &noPermissions,
AccessLevel: AccessLevel(0),
AccessLevelDescription: String("devops"),
},
},
Expand Down

0 comments on commit cad3179

Please sign in to comment.