From 6b7a0dcde1e8ec14364d9cc44e553ba6eef0f138 Mon Sep 17 00:00:00 2001 From: "Owen.Morgan-Jones" Date: Tue, 17 Mar 2026 12:59:26 +0000 Subject: [PATCH 1/2] Ensures no size arg is handled for leader & loserboards --- .../Slack/EventHandlers/GetLeaderBoardHandlerTests.cs | 8 +++++--- .../Slack/EventHandlers/GetLoserBoardHandlerTests.cs | 8 +++++--- .../Slack/MessageEventHandlers/GetLeaderBoardHandler.cs | 2 +- .../Slack/MessageEventHandlers/GetLoserBoardHandler.cs | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Bottomly.Tests/Slack/EventHandlers/GetLeaderBoardHandlerTests.cs b/Bottomly.Tests/Slack/EventHandlers/GetLeaderBoardHandlerTests.cs index 6886954..daba2b5 100644 --- a/Bottomly.Tests/Slack/EventHandlers/GetLeaderBoardHandlerTests.cs +++ b/Bottomly.Tests/Slack/EventHandlers/GetLeaderBoardHandlerTests.cs @@ -36,12 +36,14 @@ public void CanHandle_ValidEventWithSize_ReturnsTrue() => [Fact] public void CanHandle_InvalidEvent_ReturnsFalse() => _handler.CanHandle(CreateMessage("hello")).ShouldBeFalse(); - [Fact] - public async Task HandleAsync_NoSize_CallsCommandWithDefaultSize3() + [Theory] + [InlineData("_leaderboard")] + [InlineData("_leaderboard ")] + public async Task HandleAsync_NoSize_CallsCommandWithDefaultSize3(string message) { _mockKarmaRepo.Setup(r => r.GetLeaderBoardAsync(3)).ReturnsAsync(new List().AsReadOnly()); - await _handler.HandleAsync(CreateMessage("_leaderboard ")); + await _handler.HandleAsync(CreateMessage(message)); _mockKarmaRepo.Verify(r => r.GetLeaderBoardAsync(3), Times.Once()); } diff --git a/Bottomly.Tests/Slack/EventHandlers/GetLoserBoardHandlerTests.cs b/Bottomly.Tests/Slack/EventHandlers/GetLoserBoardHandlerTests.cs index 264f80c..a240de1 100644 --- a/Bottomly.Tests/Slack/EventHandlers/GetLoserBoardHandlerTests.cs +++ b/Bottomly.Tests/Slack/EventHandlers/GetLoserBoardHandlerTests.cs @@ -36,12 +36,14 @@ public void CanHandle_ValidEventWithSize_ReturnsTrue() => [Fact] public void CanHandle_InvalidEvent_ReturnsFalse() => _handler.CanHandle(CreateMessage("hello")).ShouldBeFalse(); - [Fact] - public async Task HandleAsync_NoSize_CallsCommandWithDefaultSize3() + [Theory] + [InlineData("_leaderboard")] + [InlineData("_leaderboard ")] + public async Task HandleAsync_NoSize_CallsCommandWithDefaultSize3(string message) { _mockKarmaRepo.Setup(r => r.GetLoserBoardAsync(3)).ReturnsAsync(new List().AsReadOnly()); - await _handler.HandleAsync(CreateMessage("_loserboard ")); + await _handler.HandleAsync(CreateMessage(message)); _mockKarmaRepo.Verify(r => r.GetLoserBoardAsync(3), Times.Once()); } diff --git a/Bottomly/Slack/MessageEventHandlers/GetLeaderBoardHandler.cs b/Bottomly/Slack/MessageEventHandlers/GetLeaderBoardHandler.cs index a607d19..8e022fa 100644 --- a/Bottomly/Slack/MessageEventHandlers/GetLeaderBoardHandler.cs +++ b/Bottomly/Slack/MessageEventHandlers/GetLeaderBoardHandler.cs @@ -21,7 +21,7 @@ public class GetLeaderBoardHandler( protected override async Task InvokeHandlerLogicAsync(MessageEvent message) { - var sizeArg = message.Text![CommandTrigger.Length..]; + var sizeArg = message.Text![CommandTrigger.Trim().Length..]; var size = int.TryParse(sizeArg, out var parsed) && parsed > 0 ? parsed : 3; var result = await repository.GetLeaderBoardAsync(size); diff --git a/Bottomly/Slack/MessageEventHandlers/GetLoserBoardHandler.cs b/Bottomly/Slack/MessageEventHandlers/GetLoserBoardHandler.cs index 36f32cb..63437c3 100644 --- a/Bottomly/Slack/MessageEventHandlers/GetLoserBoardHandler.cs +++ b/Bottomly/Slack/MessageEventHandlers/GetLoserBoardHandler.cs @@ -21,7 +21,7 @@ public class GetLoserBoardHandler( protected override async Task InvokeHandlerLogicAsync(MessageEvent message) { - var sizeArg = message.Text![CommandTrigger.Length..]; + var sizeArg = message.Text![CommandTrigger.Trim().Length..]; var size = int.TryParse(sizeArg, out var parsed) && parsed > 0 ? parsed : 3; var result = await repository.GetLoserBoardAsync(size); From e48ea18aa74d0e5721a1a6628b18ceca396f1f67 Mon Sep 17 00:00:00 2001 From: "Owen.Morgan-Jones" Date: Tue, 17 Mar 2026 13:08:13 +0000 Subject: [PATCH 2/2] removes push to test and always push to live on a successful CI build --- .github/workflows/push_to_live.yml | 7 +++-- .github/workflows/push_to_test.yml | 48 ------------------------------ bottomly.net.slnx | 1 - 3 files changed, 5 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/push_to_test.yml diff --git a/.github/workflows/push_to_live.yml b/.github/workflows/push_to_live.yml index e472479..9efa657 100644 --- a/.github/workflows/push_to_live.yml +++ b/.github/workflows/push_to_live.yml @@ -1,11 +1,14 @@ --- on: - release: - types: [created] + workflow_run: + workflows: [".NET Build and Test"] + types: [completed] + branches: [main] name: Push to Live jobs: build-and-deploy: runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} environment: name: live steps: diff --git a/.github/workflows/push_to_test.yml b/.github/workflows/push_to_test.yml deleted file mode 100644 index 234cace..0000000 --- a/.github/workflows/push_to_test.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- -on: push - # release: - # types: - # - created -name: Push to Test -jobs: - build-and-deploy: - runs-on: ubuntu-latest - environment: - name: test - steps: - # checkout the repo - - name: Checkout GitHub Action - uses: actions/checkout@main - - name: Login via Azure CLI - uses: azure/login@v1.4.5 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - name: Build and push image - uses: azure/docker-login@v1 - with: - login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }} - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_PASSWORD }} - - run: | - docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }} - docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }} - - name: Deploy to Azure Container Instances - uses: azure/aci-deploy@v1 - with: - resource-group: ${{ secrets.RESOURCE_GROUP }} - dns-name-label: ${{ secrets.RESOURCE_GROUP }}${{ github.run_number }} - image: ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }} - registry-login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }} - registry-username: ${{ secrets.REGISTRY_USERNAME }} - registry-password: ${{ secrets.REGISTRY_PASSWORD }} - name: bottomly-test - location: uk south - environment-variables: bottomly_giphy_api_key=${{ secrets.GIPHY_API_KEY }} - bottomly_google_api_key=${{ secrets.GOOGLE_API_KEY }} - bottomly_google_cse_id=${{ secrets.GOOGLE_CSE_ID }} - bottomly_slack_bot_token=${{ secrets.SLACK_TOKEN }} - bottomly_slack_app_token=${{ secrets.SLACK_APP_TOKEN }} - bottomly_prefix=${{ secrets.PREFIX }} - bottomly_env=${{ secrets.ENV }} - ConnectionStrings__mongodb=${{ secrets.MONGO_CONN_STR }} - bottomly_github_token=${{ secrets.RELEASE_HISTORY_TOKEN }} diff --git a/bottomly.net.slnx b/bottomly.net.slnx index 31f93d5..0086036 100644 --- a/bottomly.net.slnx +++ b/bottomly.net.slnx @@ -2,7 +2,6 @@ -