From 96b103054383d9b83216372da81dff6b791bd478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cmbt1=E2=80=9D?= Date: Wed, 15 Nov 2023 13:19:47 +0000 Subject: [PATCH 1/3] Second Test passing --- Demo/dbo.GetDiscount.sql | 2 +- Tests/GetDiscountTests.sql | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Demo/dbo.GetDiscount.sql b/Demo/dbo.GetDiscount.sql index 3a7a7c2..9322fa4 100644 --- a/Demo/dbo.GetDiscount.sql +++ b/Demo/dbo.GetDiscount.sql @@ -6,4 +6,4 @@ CREATE FUNCTION dbo.GetDiscount(@amount DECIMAL(13,2)) RETURNS TABLE AS RETURN - SELECT 0 Discount; + SELECT CASE WHEN @amount>50 THEN @amount*.1 ELSE 0 END Discount; diff --git a/Tests/GetDiscountTests.sql b/Tests/GetDiscountTests.sql index bdb7f43..62247c9 100644 --- a/Tests/GetDiscountTests.sql +++ b/Tests/GetDiscountTests.sql @@ -20,3 +20,12 @@ BEGIN EXEC tSQLt.AssertEqualsTable '#expected','#actual'; END; GO +CREATE PROCEDURE GetDiscountTests.[test 10% discount if amount greater 50] +AS +BEGIN + SELECT Discount INTO #actual FROM dbo.GetDiscount(51.00); + SELECT TOP(0) A.* INTO #expected FROM #actual X LEFT JOIN #actual A ON 1=0; + INSERT INTO #expected VALUES(5.1); + EXEC tSQLt.AssertEqualsTable '#expected','#actual'; +END; +GO From 0114a010dbb992cdee27bd0da4374f81e6631d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cmbt1=E2=80=9D?= Date: Wed, 15 Nov 2023 13:22:18 +0000 Subject: [PATCH 2/3] third test is passing --- Demo/dbo.GetDiscount.sql | 2 +- Tests/GetDiscountTests.sql | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Demo/dbo.GetDiscount.sql b/Demo/dbo.GetDiscount.sql index 9322fa4..eafb77c 100644 --- a/Demo/dbo.GetDiscount.sql +++ b/Demo/dbo.GetDiscount.sql @@ -6,4 +6,4 @@ CREATE FUNCTION dbo.GetDiscount(@amount DECIMAL(13,2)) RETURNS TABLE AS RETURN - SELECT CASE WHEN @amount>50 THEN @amount*.1 ELSE 0 END Discount; + SELECT CASE WHEN @amount>=50 THEN @amount*.1 ELSE 0 END Discount; diff --git a/Tests/GetDiscountTests.sql b/Tests/GetDiscountTests.sql index 62247c9..55562f1 100644 --- a/Tests/GetDiscountTests.sql +++ b/Tests/GetDiscountTests.sql @@ -29,3 +29,12 @@ BEGIN EXEC tSQLt.AssertEqualsTable '#expected','#actual'; END; GO +CREATE PROCEDURE GetDiscountTests.[test 10% discount if amount equal 50] +AS +BEGIN + SELECT Discount INTO #actual FROM dbo.GetDiscount(50.00); + SELECT TOP(0) A.* INTO #expected FROM #actual X LEFT JOIN #actual A ON 1=0; + INSERT INTO #expected VALUES(5.0); + EXEC tSQLt.AssertEqualsTable '#expected','#actual'; +END; +GO From d1fccb7b0786cc8846d94ca11fb71e4098324d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cmbt1=E2=80=9D?= Date: Wed, 15 Nov 2023 13:45:40 +0000 Subject: [PATCH 3/3] added merge script for demo --- Tools/MergeMain2Work.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 Tools/MergeMain2Work.sh diff --git a/Tools/MergeMain2Work.sh b/Tools/MergeMain2Work.sh new file mode 100755 index 0000000..fc66fbf --- /dev/null +++ b/Tools/MergeMain2Work.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +cd "$(dirname "$0")" +cd .. + +git fetch origin + +# Get the name of the current branch +current_branch=$(git branch --show-current) + +# Check if the current branch follows the naming pattern 'workYYYYMMDDHHMMSS' +if [[ $current_branch =~ ^work[0-9]{14}$ ]]; then + # Extract the datetime part from the branch name + datetime_part=${current_branch:4} + + # Construct the parent branch name + parent_branch="main$datetime_part" + + # Check if the parent branch exists in the remote repository + if git show-ref --verify --quiet "refs/remotes/origin/$parent_branch"; then + # Parent branch exists, so create a pull request + echo "Merging from $parent_branch to $current_branch..." + git merge "origin/$parent_branch" + else + echo "Parent branch $parent_branch does not exist in the remote repository." + exit 1 + fi +else + echo "The current branch name does not follow the expected naming pattern." + exit 1 +fi