Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parametermanager): Added samples for delete, enable or disable parameter or parameter version #2934

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Google.Cloud.ParameterManager.V1;

[Collection(nameof(ParameterManagerFixture))]
public class DeleteParamTests
{
private readonly ParameterManagerFixture _fixture;
private readonly DeleteParamSample _sample;

public DeleteParamTests(ParameterManagerFixture fixture)
{
_fixture = fixture;
_sample = new DeleteParamSample();
}

[Fact]
public void DeleteParam()
{
ParameterName parameterName = _fixture.ParameterNameToDelete;
_sample.DeleteParam(projectId: parameterName.ProjectId, parameterId: parameterName.ParameterId);

ParameterManagerClient client = ParameterManagerClient.Create();
Assert.Throws<Grpc.Core.RpcException>(() => client.GetParameter(parameterName));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Google.Cloud.ParameterManager.V1;

[Collection(nameof(ParameterManagerFixture))]
public class DeleteParamVersionTests
{
private readonly ParameterManagerFixture _fixture;
private readonly DeleteParamVersionSample _sample;

public DeleteParamVersionTests(ParameterManagerFixture fixture)
{
_fixture = fixture;
_sample = new DeleteParamVersionSample();
}

[Fact]
public void DeleteParamVersion()
{
ParameterVersionName parameterVersionName = _fixture.ParameterVersionNameToDelete;
_sample.DeleteParamVersion(projectId: parameterVersionName.ProjectId, parameterId: parameterVersionName.ParameterId, versionId: parameterVersionName.ParameterVersionId);

ParameterManagerClient client = ParameterManagerClient.Create();
Assert.Throws<Grpc.Core.RpcException>(() => client.GetParameterVersion(parameterVersionName));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Google.Cloud.ParameterManager.V1;

[Collection(nameof(ParameterManagerFixture))]
public class DisableParamVersionTests
{
private readonly ParameterManagerFixture _fixture;
private readonly DisableParamVersionSample _sample;

public DisableParamVersionTests(ParameterManagerFixture fixture)
{
_fixture = fixture;
_sample = new DisableParamVersionSample();
}

[Fact]
public void DisableParamVersion()
{
ParameterVersion result = _sample.DisableParamVersion(projectId: _fixture.ProjectId, parameterId: _fixture.ParameterId, versionId: _fixture.ParameterVersionId);

Assert.NotNull(result);
Assert.Equal(result.Name, _fixture.ParameterVersionToRender.Name);
Assert.True(result.Disabled);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Google.Cloud.ParameterManager.V1;

[Collection(nameof(ParameterManagerFixture))]
public class EnableParamVersionTests
{
private readonly ParameterManagerFixture _fixture;
private readonly EnableParamVersionSample _sample;

public EnableParamVersionTests(ParameterManagerFixture fixture)
{
_fixture = fixture;
_sample = new EnableParamVersionSample();
}

[Fact]
public void EnableParamVersion()
{
ParameterVersion result = _sample.EnableParamVersion(projectId: _fixture.ProjectId, parameterId: _fixture.ParameterId, versionId: _fixture.ParameterVersionId);

Assert.NotNull(result);
Assert.Equal(result.Name, _fixture.ParameterVersionToRender.Name);
Assert.False(result.Disabled);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
<PackageReference Include="Google.Cloud.Iam.V1" Version="3.4.0" />
<PackageReference Include="Google.Cloud.SecretManager.V1" Version="2.5.0" />
<PackageReference Include="JUnitTestLogger" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ParameterManager.Samples\ParameterManager.Samples.csproj" />
</ItemGroup>

</Project>
Loading