Skip to content

Commit

Permalink
Bookkeeping unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomi7732 committed Dec 4, 2024
1 parent 991b8a8 commit e974481
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/UnitTests/PodInfoManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task GetMyPodAsyncShouldGetCorrectPod()
containerIdHolderMock.Setup(c => c.ContainerId).Returns("containerId");

PodInfoManager target = new PodInfoManager(k8sQueryClientMock.Object, containerIdHolderMock.Object, new IPodNameProvider[] { podNameProviderMock.Object });
V1Pod result = await target.GetMyPodAsync(default).ConfigureAwait(false);
V1Pod result = await target.GetMyPodAsync(default);

Assert.NotNull(result);
Assert.Single(result.Status.ContainerStatuses);
Expand All @@ -58,7 +58,7 @@ public async Task GetMyPodAsyncShouldLeveragePodNameProviders()
k8sQueryClientMock.Setup(c => c.GetPodByNameAsync(It.IsAny<string>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult(podsArray.FirstOrDefault(item => item.Metadata.Name == providerPodName)));

PodInfoManager target = new PodInfoManager(k8sQueryClientMock.Object, containerIdHolderMock.Object, new IPodNameProvider[] { podNameProviderMock.Object });
V1Pod result = await target.GetMyPodAsync(default).ConfigureAwait(false);
V1Pod result = await target.GetMyPodAsync(default);

Assert.NotNull(result);
Assert.Single(result.Status.ContainerStatuses);
Expand Down Expand Up @@ -88,7 +88,7 @@ public async Task GetMyPodAsyncShouldFallbackToUseContainerIdWhenProvidedPodName
containerIdHolderMock.Setup(c => c.ContainerId).Returns(targetContainerId);

PodInfoManager target = new PodInfoManager(k8sQueryClientMock.Object, containerIdHolderMock.Object, new IPodNameProvider[] { podNameProviderMock.Object });
V1Pod result = await target.GetMyPodAsync(default).ConfigureAwait(false);
V1Pod result = await target.GetMyPodAsync(default);

Assert.NotNull(result);
Assert.Single(result.Status.ContainerStatuses);
Expand Down Expand Up @@ -119,7 +119,7 @@ public async Task GetMyPodAsyncShouldSupportMultipleIPodNameProviders()
podNameProviderMock2.Setup(p => p.TryGetPodName(out providerPodName2)).Returns(true); // the provider returns true with pod name.

PodInfoManager target = new PodInfoManager(k8sQueryClientMock.Object, containerIdHolderMock.Object, new IPodNameProvider[] { podNameProviderMock.Object, podNameProviderMock2.Object });
V1Pod result = await target.GetMyPodAsync(default).ConfigureAwait(false);
V1Pod result = await target.GetMyPodAsync(default);

Assert.NotNull(result);
Assert.Single(result.Status.ContainerStatuses);
Expand Down
2 changes: 1 addition & 1 deletion tests/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" />
<PackageReference Include="Moq" Version="4.*" />
<PackageReference Include="xunit" Version="2.8.*" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.*" />
Expand Down

0 comments on commit e974481

Please sign in to comment.