-
Notifications
You must be signed in to change notification settings - Fork 0
DeleteTable init #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| name: DeleteTable_release | ||
| permissions: | ||
| contents: write | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| uses: FrendsPlatform/FrendsTasks/.github/workflows/release.yml@main | ||
| with: | ||
| workdir: Frends.AzureTableStorage.DeleteTable | ||
| dotnet_version: 8.0.x | ||
| strict_analyzers: true | ||
| secrets: | ||
| feed_api_key: ${{ secrets.TASKS_FEED_API_KEY }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: DeleteTable_test_on_main | ||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'Frends.AzureTableStorage.DeleteTable/**' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| uses: FrendsPlatform/FrendsTasks/.github/workflows/linux_build_main.yml@main | ||
| with: | ||
| workdir: Frends.AzureTableStorage.DeleteTable | ||
| dotnet_version: 8.0.x | ||
| strict_analyzers: true | ||
| env_var_name_1: Frends_AzureTableStorage_ConnString | ||
| env_var_name_2: Frends_AzureTableStorage_AccountName | ||
| env_var_name_3: Frends_AzureTableStorage_TenantID | ||
| env_var_name_4: Frends_AzureTableStorage_ClientID | ||
| env_var_name_5: Frends_AzureTableStorage_ClientSecret | ||
| env_var_name_6: Frends_AzureTableStorage_SasToken | ||
| secrets: | ||
| badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }} | ||
| env_var_value_1: ${{ secrets.FRENDS_AZURETABLESTORAGE_CONNSTRING }} | ||
| env_var_value_2: ${{ secrets.FRENDS_AZURETABLESTORAGE_ACCOUNTNAME }} | ||
| env_var_value_3: ${{ secrets.FRENDS_AZURETABLESTORAGE_TENANTID }} | ||
| env_var_value_4: ${{ secrets.FRENDS_AZURETABLESTORAGE_CLIENTID }} | ||
| env_var_value_5: ${{ secrets.FRENDS_AZURETABLESTORAGE_CLIENTSECRET }} | ||
| env_var_value_6: ${{ secrets.FRENDS_AZURETABLESTORAGE_SASTOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: DeleteTable_test_on_push | ||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches-ignore: | ||
| - main | ||
| paths: | ||
| - 'Frends.AzureTableStorage.DeleteTable/**' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| uses: FrendsPlatform/FrendsTasks/.github/workflows/linux_build_test.yml@main | ||
| with: | ||
| workdir: Frends.AzureTableStorage.DeleteTable | ||
| dotnet_version: 8.0.x | ||
| strict_analyzers: true | ||
| env_var_name_1: Frends_AzureTableStorage_ConnString | ||
| env_var_name_2: Frends_AzureTableStorage_AccountName | ||
| env_var_name_3: Frends_AzureTableStorage_TenantID | ||
| env_var_name_4: Frends_AzureTableStorage_ClientID | ||
| env_var_name_5: Frends_AzureTableStorage_ClientSecret | ||
| env_var_name_6: Frends_AzureTableStorage_SasToken | ||
| secrets: | ||
| badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }} | ||
| test_feed_api_key: ${{ secrets.TASKS_TEST_FEED_API_KEY }} | ||
| env_var_value_1: ${{ secrets.FRENDS_AZURETABLESTORAGE_CONNSTRING }} | ||
| env_var_value_2: ${{ secrets.FRENDS_AZURETABLESTORAGE_ACCOUNTNAME }} | ||
| env_var_value_3: ${{ secrets.FRENDS_AZURETABLESTORAGE_TENANTID }} | ||
| env_var_value_4: ${{ secrets.FRENDS_AZURETABLESTORAGE_CLIENTID }} | ||
| env_var_value_5: ${{ secrets.FRENDS_AZURETABLESTORAGE_CLIENTSECRET }} | ||
| env_var_value_6: ${{ secrets.FRENDS_AZURETABLESTORAGE_SASTOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Changelog | ||
|
|
||
| ## [1.0.0] - 2026-09-01 | ||
|
|
||
| ### Added | ||
|
|
||
| - Initial implementation of DeleteTable task for Azure Table Storage |
14 changes: 14 additions & 0 deletions
14
Frends.AzureTableStorage.DeleteTable/Frends.AzureTableStorage.DeleteTable.Tests/.env.example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Rename this file to .env to run tests locally | ||
|
|
||
| # Connection String authentication (recommended for local testing) | ||
| Frends_AzureTableStorage_ConnString="DefaultEndpointsProtocol=https;AccountName=youraccount;AccountKey=yourkey;EndpointSuffix=core.windows.net" | ||
|
|
||
| # OAuth2 authentication | ||
| Frends_AzureTableStorage_AccountName="youraccount" | ||
| Frends_AzureTableStorage_TenantID="12345678-1234-1234-1234-123456789012" | ||
| Frends_AzureTableStorage_ClientID="12345678-1234-1234-1234-123456789012" | ||
| Frends_AzureTableStorage_ClientSecret="your-client-secret" | ||
|
|
||
| # SAS Token authentication | ||
| Frends_AzureTableStorage_AccountName="youraccount" | ||
|
jefim marked this conversation as resolved.
|
||
| Frends_AzureTableStorage_SasToken="?sv=2021-06-08&ss=t&srt=sco&sp=rwdlacu&se=2024-12-31T23:59:59Z&st=2024-01-01T00:00:00Z&spr=https&sig=..." | ||
|
MichalFrends1 marked this conversation as resolved.
|
||
121 changes: 121 additions & 0 deletions
121
...reTableStorage.DeleteTable/Frends.AzureTableStorage.DeleteTable.Tests/ErrorHandlerTest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| using System; | ||
| using System.ComponentModel.DataAnnotations; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Frends.AzureTableStorage.DeleteTable.Definitions; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Frends.AzureTableStorage.DeleteTable.Tests; | ||
|
|
||
| [TestFixture] | ||
| internal class ErrorHandlerTest : TestBase | ||
| { | ||
| private const string CustomErrorMessage = "Custom error occurred during table creation"; | ||
|
|
||
| [Test] | ||
| public void Should_Throw_Error_When_ThrowErrorOnFailure_Is_True() | ||
| { | ||
| var input = new Input { TableName = "TestTable" }; | ||
| var connection = new Connection | ||
| { | ||
| ConnectionMethod = ConnectionMethod.ConnectionString, | ||
| ConnectionString = "Invalid", | ||
| }; | ||
| var options = DefaultOptions(); | ||
| options.ThrowErrorOnFailure = true; | ||
|
|
||
| Func<Task> action = async () => { await AzureTableStorage.DeleteTable(input, connection, options, CancellationToken.None); }; | ||
| var ex = Assert.ThrowsAsync<ArgumentException>(action); | ||
| Assert.That(ex, Is.Not.Null); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task Should_Return_Failed_Result_When_ThrowErrorOnFailure_Is_False() | ||
| { | ||
| var input = new Input { TableName = "TestTable" }; | ||
| var connection = new Connection | ||
| { | ||
| ConnectionMethod = ConnectionMethod.ConnectionString, | ||
| ConnectionString = "Invalid", | ||
| }; | ||
| var options = DefaultOptions(); | ||
| options.ThrowErrorOnFailure = false; | ||
|
|
||
| var result = await AzureTableStorage.DeleteTable(input, connection, options, CancellationToken.None); | ||
|
|
||
| Assert.That(result.Success, Is.False); | ||
| Assert.That(result.Error, Is.Not.Null); | ||
| Assert.That(result.Error.Message, Is.Not.Empty); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Should_Use_Custom_ErrorMessageOnFailure() | ||
| { | ||
| var input = new Input { TableName = "TestTable" }; | ||
| var connection = new Connection | ||
| { | ||
| ConnectionMethod = ConnectionMethod.ConnectionString, | ||
| ConnectionString = "Invalid", | ||
| }; | ||
| var options = DefaultOptions(); | ||
| options.ErrorMessageOnFailure = CustomErrorMessage; | ||
| options.ThrowErrorOnFailure = true; | ||
|
|
||
| Func<Task> action = async () => { await AzureTableStorage.DeleteTable(input, connection, options, CancellationToken.None); }; | ||
| var ex = Assert.ThrowsAsync<Exception>(action); | ||
| Assert.That(ex, Is.Not.Null); | ||
| Assert.That(ex.Message, Does.Contain(CustomErrorMessage)); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task Should_Return_Custom_ErrorMessage_When_ThrowErrorOnFailure_Is_False() | ||
| { | ||
| var input = new Input { TableName = "TestTable" }; | ||
| var connection = new Connection | ||
| { | ||
| ConnectionMethod = ConnectionMethod.ConnectionString, | ||
| ConnectionString = "Invalid", | ||
| }; | ||
| var options = DefaultOptions(); | ||
| options.ErrorMessageOnFailure = CustomErrorMessage; | ||
| options.ThrowErrorOnFailure = false; | ||
|
|
||
| var result = await AzureTableStorage.DeleteTable(input, connection, options, CancellationToken.None); | ||
|
|
||
| Assert.That(result.Success, Is.False); | ||
| Assert.That(result.Error, Is.Not.Null); | ||
| Assert.That(result.Error.Message, Does.Contain(CustomErrorMessage)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Should_Always_Throw_OperationCanceledException() | ||
| { | ||
| var input = new Input { TableName = "TestTable" }; | ||
| var options = DefaultOptions(); | ||
| options.ThrowErrorOnFailure = false; // Even with this set to false | ||
|
|
||
| var cts = new CancellationTokenSource(); | ||
| cts.Cancel(); | ||
|
|
||
| Func<Task> action = async () => { await AzureTableStorage.DeleteTable(input, DefaultConnectionStringConnection(), options, cts.Token); }; | ||
| var ex = Assert.ThrowsAsync<TaskCanceledException>(action); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Should_Throw_ValidationException_When_TableName_Is_Empty() | ||
| { | ||
| var input = new Input { TableName = string.Empty }; | ||
| var connection = new Connection | ||
| { | ||
| ConnectionMethod = ConnectionMethod.ConnectionString, | ||
| ConnectionString = "valid-connection-string", | ||
| }; | ||
| var options = DefaultOptions(); | ||
|
|
||
| Func<Task> action = async () => { await AzureTableStorage.DeleteTable(input, connection, options, CancellationToken.None); }; | ||
| var ex = Assert.ThrowsAsync<ValidationException>(action); | ||
|
|
||
| Assert.That(ex, Is.Not.Null); | ||
| Assert.That(ex.Message, Does.Contain("TableName")); | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
...nds.AzureTableStorage.DeleteTable.Tests/Frends.AzureTableStorage.DeleteTable.Tests.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <IsPackable>false</IsPackable> | ||
| <Nullable>disable</Nullable> | ||
| </PropertyGroup> | ||
|
MichalFrends1 marked this conversation as resolved.
|
||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Frends.AzureTableStorage.DeleteTable\Frends.AzureTableStorage.DeleteTable.csproj"/> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Include=".env" CopyToOutputDirectory="PreserveNewest" Condition="Exists('.env')"/> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556"/> | ||
| <PackageReference Include="coverlet.collector" Version="6.*"/> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.*"/> | ||
| <PackageReference Include="NUnit" Version="4.*"/> | ||
| <PackageReference Include="NUnit3TestAdapter" Version="6.*"/> | ||
| <PackageReference Include="dotenv.net" Version="4.*"/> | ||
| </ItemGroup> | ||
| </Project> | ||
130 changes: 130 additions & 0 deletions
130
...ureTableStorage.DeleteTable/Frends.AzureTableStorage.DeleteTable.Tests/FunctionalTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| using System; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Azure.Data.Tables; | ||
| using Frends.AzureTableStorage.DeleteTable.Definitions; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Frends.AzureTableStorage.DeleteTable.Tests; | ||
|
|
||
| [TestFixture] | ||
| internal class FunctionalTests : TestBase | ||
| { | ||
| private string tableName; | ||
| private Input input; | ||
|
|
||
| [SetUp] | ||
| public async Task SetUp() | ||
| { | ||
| tableName = $"TestTable{DateTime.UtcNow:yyyyMMddHHmmssfff}"; | ||
| input = new Input { TableName = tableName }; | ||
|
|
||
| if (!string.IsNullOrEmpty(ConnectionString)) | ||
| { | ||
| var serviceClient = new TableServiceClient(ConnectionString); | ||
| await serviceClient.CreateTableIfNotExistsAsync(tableName); | ||
| } | ||
| } | ||
|
|
||
| [TearDown] | ||
| public async Task TearDown() | ||
| { | ||
| if (!string.IsNullOrEmpty(ConnectionString)) | ||
| { | ||
| try | ||
| { | ||
| var serviceClient = new TableServiceClient(ConnectionString); | ||
| await serviceClient.DeleteTableAsync(tableName); | ||
| } | ||
| catch | ||
| { | ||
| // Ignore cleanup errors | ||
| } | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task DeleteTable_WithConnectionString_ShouldDeleteTable() | ||
| { | ||
| var result = await AzureTableStorage.DeleteTable(input, DefaultConnectionStringConnection(), DefaultOptions(), CancellationToken.None); | ||
|
|
||
| Assert.That(result.Success, Is.True); | ||
| Assert.That(result.TableName, Is.EqualTo(input.TableName)); | ||
| Assert.That(result.Deleted, Is.True); | ||
| Assert.That(result.TableUri, Is.Not.Empty); | ||
| Assert.That(result.Error, Is.Null); | ||
|
|
||
| var serviceClient = new TableServiceClient(ConnectionString); | ||
| Assert.That(await TableExistsAsync(serviceClient, tableName), Is.False); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task DeleteTable_WhenTableDoesNotExist_ShouldReturnDeletedFalse() | ||
| { | ||
| var nonExistentTable = $"NonExistent{DateTime.UtcNow:yyyyMMddHHmmssfff}"; | ||
| var testInput = new Input { TableName = nonExistentTable }; | ||
|
|
||
| var result = await AzureTableStorage.DeleteTable(testInput, DefaultConnectionStringConnection(), DefaultOptions(), CancellationToken.None); | ||
|
|
||
| Assert.That(result.Success, Is.True); | ||
| Assert.That(result.TableName, Is.EqualTo(nonExistentTable)); | ||
| Assert.That(result.Deleted, Is.False); | ||
| Assert.That(result.Error, Is.Null); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task DeleteTable_WithFailIfTableNotExists_ShouldReturnError() | ||
| { | ||
| var nonExistentTable = $"NonExistent{DateTime.UtcNow:yyyyMMddHHmmssfff}"; | ||
| var testInput = new Input { TableName = nonExistentTable }; | ||
|
|
||
| var options = DefaultOptions(); | ||
| options.FailIfTableNotExists = true; | ||
| options.ThrowErrorOnFailure = false; | ||
| var result = await AzureTableStorage.DeleteTable(testInput, DefaultConnectionStringConnection(), options, CancellationToken.None); | ||
|
|
||
| Assert.That(result.Success, Is.False); | ||
| Assert.That(result.Error, Is.Not.Null); | ||
| Assert.That(result.Error.Message, Does.Contain("does not exist")); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task DeleteTable_WithOAuth2_ShouldDeleteTable() | ||
| { | ||
| var result = await AzureTableStorage.DeleteTable(input, DefaultOAuth2Connection(), DefaultOptions(), CancellationToken.None); | ||
|
|
||
| Assert.That(result.Success, Is.True); | ||
| Assert.That(result.TableName, Is.EqualTo(input.TableName)); | ||
| Assert.That(result.Deleted, Is.True); | ||
| Assert.That(result.TableUri, Is.Not.Empty); | ||
| Assert.That(result.Error, Is.Null); | ||
|
|
||
| var serviceClient = new TableServiceClient(ConnectionString); | ||
| Assert.That(await TableExistsAsync(serviceClient, tableName), Is.False); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task DeleteTable_WithSasToken_ShouldDeleteTable() | ||
| { | ||
| var result = await AzureTableStorage.DeleteTable(input, DefaultSasTokenConnection(), DefaultOptions(), CancellationToken.None); | ||
|
|
||
| Assert.That(result.Success, Is.True); | ||
| Assert.That(result.TableName, Is.EqualTo(input.TableName)); | ||
| Assert.That(result.Deleted, Is.True); | ||
| Assert.That(result.TableUri, Is.Not.Empty); | ||
| Assert.That(result.Error, Is.Null); | ||
|
|
||
| var serviceClient = new TableServiceClient(ConnectionString); | ||
| Assert.That(await TableExistsAsync(serviceClient, tableName), Is.False); | ||
| } | ||
|
|
||
| private static async Task<bool> TableExistsAsync(TableServiceClient serviceClient, string tableName) | ||
| { | ||
| await foreach (var table in serviceClient.QueryAsync(filter: $"TableName eq '{tableName}'")) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
...TableStorage.DeleteTable/Frends.AzureTableStorage.DeleteTable.Tests/GlobalSuppressions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| [assembly: SuppressMessage("StyleCop.CSharp.SpecialRules", "SA0001::XmlCommentAnalysisDisabled", Justification = "Following Frends documentation guidelines")] | ||
| [assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:PrefixLocalCallsWithThis", Justification = "Following Frends documentation guidelines")] | ||
| [assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1200:UsingDirectivesMustBePlacedWithinNamespace", Justification = "Following Frends documentation guidelines")] | ||
| [assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:BracesMustNotBeOmitted", Justification = "Following Frends documentation guidelines")] | ||
| [assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Documentation checked by custom analyzers")] | ||
| [assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:FileMustHaveHeader", Justification = "Following Frends documentation guidelines")] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.