diff --git a/Demo/dbo.GetDiscount.sql b/Demo/dbo.GetDiscount.sql index 3a7a7c2..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 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..55562f1 100644 --- a/Tests/GetDiscountTests.sql +++ b/Tests/GetDiscountTests.sql @@ -20,3 +20,21 @@ 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 +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 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