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

feat: update project variable with description field #1863

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions group_access_tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func TestCreateGroupAccessToken(t *testing.T) {
t.Errorf("GroupAccessTokens.CreateGroupAccessToken returned %+v, want %+v", groupAccessToken, want)
}
}

func TestRotateGroupAccessToken(t *testing.T) {
mux, client := setup(t)
mux.HandleFunc("/api/v4/groups/1/access_tokens/42/rotate", func(w http.ResponseWriter, r *http.Request) {
Expand Down
8 changes: 4 additions & 4 deletions group_boards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestGroupIssueBoardsService_GetGroupIssueBoard(t *testing.T) {
"id": 12,
"title": "10.0"
},
"labels": [
"labels": [
{
"id":1749,
"name":"my-scope1",
Expand Down Expand Up @@ -399,9 +399,9 @@ func TestGroupIssueBoardsService_UpdateIssueBoard(t *testing.T) {
},
Labels: []*GroupLabel{
{
ID: 11,
Name: "GroupLabel",
Color: "#428BCA",
ID: 11,
Name: "GroupLabel",
Color: "#428BCA",
Description: "",
},
},
Expand Down
1 change: 1 addition & 0 deletions personal_access_tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ func TestRotatePersonalAccessToken(t *testing.T) {
t.Errorf("PersonalAccessTokens.RotatePersonalAccessTokens returned %+v, want %+v", rotatedToken, want)
}
}

func TestRevokePersonalAccessToken(t *testing.T) {
mux, client := setup(t)

Expand Down
26 changes: 19 additions & 7 deletions project_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ func TestProjectVariablesService_ListVariables(t *testing.T) {
{
"key": "TEST_VARIABLE_1",
"variable_type": "env_var",
"value": "TEST_1"
"value": "TEST_1",
"description": "test variable 1"
}
]
`)
Expand All @@ -31,6 +32,7 @@ func TestProjectVariablesService_ListVariables(t *testing.T) {
Protected: false,
Masked: false,
EnvironmentScope: "",
Description: "test variable 1",
}}

pvs, resp, err := client.ProjectVariables.ListVariables(1, nil, nil)
Expand Down Expand Up @@ -66,7 +68,8 @@ func TestProjectVariablesService_GetVariable(t *testing.T) {
"variable_type": "env_var",
"value": "TEST_1",
"protected": false,
"masked": true
"masked": true,
"description": "test variable 1"
}
`)
})
Expand All @@ -78,6 +81,7 @@ func TestProjectVariablesService_GetVariable(t *testing.T) {
Protected: false,
Masked: true,
EnvironmentScope: "",
Description: "test variable 1",
}

pv, resp, err := client.ProjectVariables.GetVariable(1, "TEST_VARIABLE_1", &GetProjectVariableOptions{Filter: &VariableFilter{EnvironmentScope: "prod"}}, nil)
Expand Down Expand Up @@ -106,14 +110,16 @@ func TestProjectVariablesService_CreateVariable(t *testing.T) {

mux.HandleFunc("/api/v4/projects/1/variables", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPost)
testBody(t, r, `{"description":"new variable"}`)
fmt.Fprintf(w, `
{
"key": "NEW_VARIABLE",
"value": "new value",
"protected": false,
"variable_type": "env_var",
"masked": false,
"environment_scope": "*"
"environment_scope": "*",
"description": "new variable"
}
`)
})
Expand All @@ -125,9 +131,10 @@ func TestProjectVariablesService_CreateVariable(t *testing.T) {
Protected: false,
Masked: false,
EnvironmentScope: "*",
Description: "new variable",
}

pv, resp, err := client.ProjectVariables.CreateVariable(1, nil, nil)
pv, resp, err := client.ProjectVariables.CreateVariable(1, &CreateProjectVariableOptions{Description: Ptr("new variable")}, nil)
require.NoError(t, err)
require.NotNil(t, resp)
require.Equal(t, want, pv)
Expand All @@ -153,15 +160,16 @@ func TestProjectVariablesService_UpdateVariable(t *testing.T) {

mux.HandleFunc("/api/v4/projects/1/variables/NEW_VARIABLE", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPut)
testBody(t, r, `{"filter":{"environment_scope":"prod"}}`)
testBody(t, r, `{"description":"updated description","filter":{"environment_scope":"prod"}}`)
fmt.Fprintf(w, `
{
"key": "NEW_VARIABLE",
"value": "updated value",
"protected": false,
"variable_type": "env_var",
"masked": false,
"environment_scope": "*"
"environment_scope": "*",
"description": "updated description"
}
`)
})
Expand All @@ -173,9 +181,13 @@ func TestProjectVariablesService_UpdateVariable(t *testing.T) {
Protected: false,
Masked: false,
EnvironmentScope: "*",
Description: "updated description",
}

pv, resp, err := client.ProjectVariables.UpdateVariable(1, "NEW_VARIABLE", &UpdateProjectVariableOptions{Filter: &VariableFilter{EnvironmentScope: "prod"}}, nil)
pv, resp, err := client.ProjectVariables.UpdateVariable(1, "NEW_VARIABLE", &UpdateProjectVariableOptions{
Filter: &VariableFilter{EnvironmentScope: "prod"},
Description: Ptr("updated description"),
}, nil)
require.NoError(t, err)
require.NotNil(t, resp)
require.Equal(t, want, pv)
Expand Down
Loading