public async Task ProjectVariableCanBeUpdated() { var request = new CreateVariableRequest { VariableType = "env_var", Key = "SOME_VAR_KEY_TO_UPDATE", Value = "VALUE_VAR", EnvironmentScope = "*", Masked = true, Protected = true }; var variable = await _sut.CreateVariableAsync(GitLabApiHelper.TestProjectId, request); VariableIdsToClean.Add(request.Key); var updateRequest = new UpdateProjectVariableRequest { VariableType = "file", Key = request.Key, Value = "UpdatedValue", EnvironmentScope = "*", Masked = request.Masked, Protected = request.Protected, }; var variableUpdated = await _sut.UpdateVariableAsync(GitLabApiHelper.TestProjectId, updateRequest); variableUpdated.Should().Match <Variable>(v => v.VariableType == updateRequest.VariableType && v.Key == updateRequest.Key && v.Value == updateRequest.Value && v.EnvironmentScope == updateRequest.EnvironmentScope && v.Masked == updateRequest.Masked && v.Protected == updateRequest.Protected); }
public async Task ProjectVariablesCreated() { var request = new CreateVariableRequest { VariableType = "env_var", Key = "SOME_VAR_KEY_CREATED", Value = "VALUE_VAR", EnvironmentScope = "*", Masked = true, Protected = true }; var variable = await _sut.CreateVariableAsync(GitLabApiHelper.TestProjectId, request); variable.Should().Match <Variable>(v => v.VariableType == request.VariableType && v.Key == request.Key && v.Value == request.Value && v.EnvironmentScope == request.EnvironmentScope && v.Masked == request.Masked && v.Protected == request.Protected); VariableIdsToClean.Add(request.Key); }
/// <summary> /// Creates new project variable. /// </summary> /// <param name="projectId">The ID, path or <see cref="Project"/> of the project.</param> /// <param name="request">Create variable request.</param> /// <returns>Newly created variable.</returns> public async Task <Variable> CreateVariableAsync(ProjectId projectId, CreateVariableRequest request) { Guard.NotNull(request, nameof(request)); return(await _httpFacade.Post <Variable>($"projects/{projectId}/variables", request)); }