Skip to content

Commit

Permalink
Use ContainerFixture for BigQueryContainerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced committed Nov 23, 2024
1 parent a404df6 commit 3fe8dc1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
16 changes: 2 additions & 14 deletions tests/Testcontainers.BigQuery.Tests/BigQueryContainerTest.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
namespace Testcontainers.BigQuery;

public sealed class BigQueryContainerTest : IAsyncLifetime
public sealed class BigQueryContainerTest(ContainerFixture<BigQueryBuilder, BigQueryContainer> fixture) : IClassFixture<ContainerFixture<BigQueryBuilder, BigQueryContainer>>
{
private readonly BigQueryContainer _bigQueryContainer = new BigQueryBuilder().Build();

public Task InitializeAsync()
{
return _bigQueryContainer.StartAsync();
}

public Task DisposeAsync()
{
return _bigQueryContainer.DisposeAsync().AsTask();
}

[Fact]
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
public async Task ExecuteQueryReturnsInsertRow()
Expand All @@ -26,7 +14,7 @@ public async Task ExecuteQueryReturnsInsertRow()
var utcNowWithoutMilliseconds = new DateTime(utcNow.Year, utcNow.Month, utcNow.Day, utcNow.Hour, utcNow.Minute, utcNow.Second, DateTimeKind.Utc);

var bigQueryClientBuilder = new BigQueryClientBuilder();
bigQueryClientBuilder.BaseUri = _bigQueryContainer.GetEmulatorEndpoint();
bigQueryClientBuilder.BaseUri = fixture.Container.GetEmulatorEndpoint();
bigQueryClientBuilder.ProjectId = BigQueryBuilder.DefaultProjectId;
bigQueryClientBuilder.Credential = new Credential();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../src/Testcontainers.BigQuery/Testcontainers.BigQuery.csproj"/>
<ProjectReference Include="../../src/Testcontainers.Xunit/Testcontainers.Xunit.csproj" />
<ProjectReference Include="../Testcontainers.Commons/Testcontainers.Commons.csproj"/>
</ItemGroup>
</Project>
9 changes: 5 additions & 4 deletions tests/Testcontainers.BigQuery.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
global using System;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
global using Google.Cloud.BigQuery.V2;
global using Xunit;
global using System.Threading;
global using Google.Apis.Auth.OAuth2;
global using Google.Apis.Http;
global using Google.Apis.Http;
global using Google.Cloud.BigQuery.V2;
global using Testcontainers.Xunit;
global using Xunit;

0 comments on commit 3fe8dc1

Please sign in to comment.