Skip to content

Commit

Permalink
Add workaround for timing issue in end to end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed May 3, 2022
1 parent 77908aa commit 93325fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Tests/QueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ public async Task CanGetAll()
public async Task CanProject()
{
var account = CloudStorageAccount.DevelopmentStorageAccount;
var repo = TableRepository.Create<Book>(account, nameof(CanProject), x => x.Author, x => x.ISBN);
var repo = TableRepository.Create<Book>(account, $"{nameof(QueryTests)}{nameof(CanProject)}", x => x.Author, x => x.ISBN);

// For some reason, this test alone fails due to what looks like a timing issue in finishing creating the table
while ((await account.CreateTableServiceClient().GetTableClient(repo.TableName).CreateIfNotExistsAsync()) != null)
{
await Task.Delay(50);
}

await LoadBooksAsync(repo);

var hasResults = false;
Expand Down
7 changes: 7 additions & 0 deletions src/Tests/RepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ public async Task TableEndToEnd()
public async Task TableRecordEndToEnd()
{
var repo = TableRepository.Create<AttributedRecordEntity>(CloudStorageAccount.DevelopmentStorageAccount);

// For some reason, this test alone fails due to what looks like a timing issue in finishing creating the table
while ((await CloudStorageAccount.DevelopmentStorageAccount.CreateTableServiceClient().GetTableClient(repo.TableName).CreateIfNotExistsAsync()) != null)
{
await Task.Delay(50);
}

var entity = await repo.PutAsync(new AttributedRecordEntity("Book", "1234"));

Assert.Equal("1234", entity.ID);
Expand Down

0 comments on commit 93325fb

Please sign in to comment.