Skip to content

Pull Request from work20231115131253 to main20231115131253 #3

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

Open
wants to merge 5 commits into
base: main20231115131253
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Demo/dbo.GetDiscount.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
18 changes: 18 additions & 0 deletions Tests/GetDiscountTests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
31 changes: 31 additions & 0 deletions Tools/MergeMain2Work.sh
Original file line number Diff line number Diff line change
@@ -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