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

Commit

Permalink
update project variables client with description field
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCodear authored and svanharmelen committed Jan 16, 2024
1 parent 4e7fdb7 commit 80a3897
Showing 1 changed file with 19 additions and 7 deletions.
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, `{"filter":{"environment_scope":"prod"},"description":"updated description"}`)
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

0 comments on commit 80a3897

Please sign in to comment.