From 80a3897b5a37351c420618bf034de3359d85dc96 Mon Sep 17 00:00:00 2001 From: Jan Wolfensberger Date: Mon, 15 Jan 2024 12:10:23 +0100 Subject: [PATCH 1/3] update project variables client with description field --- project_variables_test.go | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/project_variables_test.go b/project_variables_test.go index 81307964f..504ef0c2b 100644 --- a/project_variables_test.go +++ b/project_variables_test.go @@ -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" } ] `) @@ -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) @@ -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" } `) }) @@ -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) @@ -106,6 +110,7 @@ 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", @@ -113,7 +118,8 @@ func TestProjectVariablesService_CreateVariable(t *testing.T) { "protected": false, "variable_type": "env_var", "masked": false, - "environment_scope": "*" + "environment_scope": "*", + "description": "new variable" } `) }) @@ -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) @@ -153,7 +160,7 @@ 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, `{"filter":{"environment_scope":"prod"},"description":"updated description"}`) fmt.Fprintf(w, ` { "key": "NEW_VARIABLE", @@ -161,7 +168,8 @@ func TestProjectVariablesService_UpdateVariable(t *testing.T) { "protected": false, "variable_type": "env_var", "masked": false, - "environment_scope": "*" + "environment_scope": "*", + "description": "updated description" } `) }) @@ -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) From c3f82c2c7ab4adced570e69bb00fac9e467437ac Mon Sep 17 00:00:00 2001 From: Jan Wolfensberger Date: Mon, 15 Jan 2024 12:14:45 +0100 Subject: [PATCH 2/3] format source code --- group_access_tokens_test.go | 1 + group_boards_test.go | 6 +++--- personal_access_tokens_test.go | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/group_access_tokens_test.go b/group_access_tokens_test.go index 93a358d87..657f4f233 100644 --- a/group_access_tokens_test.go +++ b/group_access_tokens_test.go @@ -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) { diff --git a/group_boards_test.go b/group_boards_test.go index dbbaff66c..a6a9d9cd6 100644 --- a/group_boards_test.go +++ b/group_boards_test.go @@ -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: "", }, }, diff --git a/personal_access_tokens_test.go b/personal_access_tokens_test.go index 36eee51ea..1236b7699 100644 --- a/personal_access_tokens_test.go +++ b/personal_access_tokens_test.go @@ -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) From 28f5cd4ed8922d10deda421454e418a8a0530f4b Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Tue, 16 Jan 2024 09:01:19 +0100 Subject: [PATCH 3/3] Fix test after reodering --- group_boards_test.go | 2 +- project_variables_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/group_boards_test.go b/group_boards_test.go index a6a9d9cd6..f3ff61571 100644 --- a/group_boards_test.go +++ b/group_boards_test.go @@ -204,7 +204,7 @@ func TestGroupIssueBoardsService_GetGroupIssueBoard(t *testing.T) { "id": 12, "title": "10.0" }, - "labels": [ + "labels": [ { "id":1749, "name":"my-scope1", diff --git a/project_variables_test.go b/project_variables_test.go index 504ef0c2b..7f2cd8e50 100644 --- a/project_variables_test.go +++ b/project_variables_test.go @@ -160,7 +160,7 @@ 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"},"description":"updated description"}`) + testBody(t, r, `{"description":"updated description","filter":{"environment_scope":"prod"}}`) fmt.Fprintf(w, ` { "key": "NEW_VARIABLE",