You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It "runs the script and logs correctly"
When run script "lib/extract-delta.sh"
The status should be success
The output should include "step start"
The output should include "Checked out to test-to-revision"
The output should include "file1.txt - included"
The output should include "file2.txt - included"
The output should include "step completion"
End
It "creates expected files"
When run script "lib/extract-delta.sh"
The file "$RESULTS_FROM_COMMIT_PATH" should be present
The file "$RESULTS_TO_COMMIT_PATH" should be present
The file "$RESULTS_EXTRACTED_DELTA_REF_PATH" should be present
The contents of file "$RESULTS_FROM_COMMIT_PATH" should equal "from-commit-sha"
The contents of file "$RESULTS_TO_COMMIT_PATH" should equal "to-commit-sha"
The contents of file "$RESULTS_EXTRACTED_DELTA_REF_PATH" should equal "test-pod"
End
Move the file setup outside of the It block
Describe 'File copying test'
Before 'setup_environment'
Before 'touch "$CHECKOUT_ROOT/$CHECKOUT_REF/file1.txt"'
Before 'touch "$MINIMIZED_CHECKOUT_ROOT/$MINIMIZED_CHECKOUT_REF/file1.txt"'
Before 'touch "$CHECKOUT_ROOT/$CHECKOUT_REF/file2.txt"'
Before 'touch "$MINIMIZED_CHECKOUT_ROOT/$MINIMIZED_CHECKOUT_REF/file2.txt"'
It "copies the correct files"
When run script "lib/extract-delta.sh"
The file "$EXTRACTED_DELTA_ROOT/$POD_NAME/file1.txt" should be present
The file "$EXTRACTED_DELTA_ROOT/$POD_NAME/file2.txt" should be present
End
End
End
`
When i run it it gives me the error 'fatal: not a git repository (or any of the parent directories): .git' but I have already creayed the git mock function in my test script :(
It would be great if anyone can give pointers on this to overcome this issue :(
Following is an extraction of the error
`1, step start: 2024-08-29T12:51:44Z
fatal: not a git repository (or any of the parent directories): .git
Running: /bin/sh [bash 5.2.26(1)-release]
FFW
Examples:
extract-delta.sh runs the script and logs correctly
When run script lib/extract-delta.sh
1.1) The output should include Checked out to test-to-revision
expected "step start: 2024-08-29T12:51:45Z
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
warning: Not a git repository. Use --no-index to compare two paths outside a working tree`
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have written my test code as follows.
`Describe 'extract-delta.sh'
Include lib/extract-delta.sh
setup_environment() {
export EXTRACT_DELTA_CONSOLE_LOG_PATH="/tmp/test/extract-delta-console-log"
export MINIMIZED_CHECKOUT_ROOT="/tmp/test/minimized-checkout-root"
export MINIMIZED_CHECKOUT_REF="test-branch"
export CHECKOUT_ROOT="/tmp/test/checkout-root"
export CHECKOUT_REF="test-branch" # Explicitly set this to match the script
export TO_REVISION="test-to-revision"
export FROM_REVISION="test-from-revision"
export EXTRACTED_DELTA_ROOT="/tmp/test/extracted-delta-root"
export POD_NAME="test-pod"
export RESULTS_FROM_COMMIT_PATH="/tmp/test/results-from-commit"
export RESULTS_TO_COMMIT_PATH="/tmp/test/results-to-commit"
export RESULTS_EXTRACTED_DELTA_REF_PATH="/tmp/test/results-extracted-delta-ref"
}
cleanup_environment() {
rm -rf /tmp/test/
}
BeforeEach 'setup_environment'
AfterEach 'cleanup_environment'
Mock_git() {
case "$1" in
checkout)
echo "Checked out to $2"
;;
rev-parse)
case "$2" in
"$FROM_REVISION") echo "from-commit-sha" ;;
"$TO_REVISION") echo "to-commit-sha" ;;
*) echo "Unknown revision" ;;
esac
;;
diff)
echo "file1.txt"
echo "file2.txt"
;;
*)
echo "Unknown command"
;;
esac
}
Replace the actual git command with the mock
BeforeEach 'alias git=Mock_git'
AfterEach 'unalias git'
It "runs the script and logs correctly"
When run script "lib/extract-delta.sh"
The status should be success
The output should include "step start"
The output should include "Checked out to test-to-revision"
The output should include "file1.txt - included"
The output should include "file2.txt - included"
The output should include "step completion"
End
It "creates expected files"
When run script "lib/extract-delta.sh"
The file "$RESULTS_FROM_COMMIT_PATH" should be present
The file "$RESULTS_TO_COMMIT_PATH" should be present
The file "$RESULTS_EXTRACTED_DELTA_REF_PATH" should be present
The contents of file "$RESULTS_FROM_COMMIT_PATH" should equal "from-commit-sha"
The contents of file "$RESULTS_TO_COMMIT_PATH" should equal "to-commit-sha"
The contents of file "$RESULTS_EXTRACTED_DELTA_REF_PATH" should equal "test-pod"
End
Move the file setup outside of the It block
Describe 'File copying test'
Before 'setup_environment'
Before 'touch "$CHECKOUT_ROOT/$CHECKOUT_REF/file1.txt"'
Before 'touch "$MINIMIZED_CHECKOUT_ROOT/$MINIMIZED_CHECKOUT_REF/file1.txt"'
Before 'touch "$CHECKOUT_ROOT/$CHECKOUT_REF/file2.txt"'
Before 'touch "$MINIMIZED_CHECKOUT_ROOT/$MINIMIZED_CHECKOUT_REF/file2.txt"'
End
End
`
When i run it it gives me the error 'fatal: not a git repository (or any of the parent directories): .git' but I have already creayed the git mock function in my test script :(
It would be great if anyone can give pointers on this to overcome this issue :(
Following is an extraction of the error
`1, step start: 2024-08-29T12:51:44Z
fatal: not a git repository (or any of the parent directories): .git
Running: /bin/sh [bash 5.2.26(1)-release]
FFW
Examples:
extract-delta.sh runs the script and logs correctly
When run script lib/extract-delta.sh
1.1) The output should include Checked out to test-to-revision
Beta Was this translation helpful? Give feedback.
All reactions