Skip to content

Commit

Permalink
Update push tests as well
Browse files Browse the repository at this point in the history
  • Loading branch information
macneale4 committed Mar 27, 2024
1 parent ec68cf6 commit f589ad0
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion integration-tests/bats/push.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
load $BATS_TEST_DIRNAME/helper/common.bash

setup() {
setup_common
# See pull.bats. Can't use common remote server setup since we have multiple databases.
setup_no_dolt_init

TESTDIRS=$(pwd)/testdirs
mkdir -p $TESTDIRS/{rem1,repo1}
Expand Down Expand Up @@ -37,6 +38,8 @@ teardown() {

@test "push: push origin" {
cd repo1
setup_remote_server

dolt push origin main

cd ../repo2
Expand All @@ -50,6 +53,7 @@ teardown() {

@test "push: push custom remote" {
cd repo1
setup_remote_server
dolt push test-remote main

cd ../repo2
Expand All @@ -63,6 +67,8 @@ teardown() {

@test "push: push without repository defined throws error" {
cd repo1
setup_remote_server

run dolt push main # should push to origin
[ "$status" -eq 1 ]
[[ "$output" =~ "fatal: remote 'main' not found." ]] || false
Expand Down Expand Up @@ -99,6 +105,8 @@ teardown() {
@test "push: push feature branch" {
cd repo1
dolt checkout -b feature

setup_remote_server
dolt push origin feature

cd ../repo2
Expand All @@ -114,6 +122,8 @@ teardown() {
@test "push: can set upstream branch with different name" {
cd repo1
dolt checkout -b other

setup_remote_server
dolt push -u origin other:remote-other

run dolt branch -r
Expand All @@ -124,6 +134,8 @@ teardown() {
@test "push: push aborts if nothing specified, upstream has different name" {
cd repo1
dolt checkout -b other

setup_remote_server
dolt push -u origin other:remote-other

run dolt push
Expand All @@ -134,6 +146,8 @@ teardown() {
@test "push: push --set-upstream persists" {
cd repo1
dolt checkout -b other

setup_remote_server
run dolt push
[ "$status" -eq 1 ]
[[ "$output" =~ "The current branch other has no upstream branch." ]] || false
Expand All @@ -147,8 +161,13 @@ teardown() {
}

@test "push: push without --set-upstream persists when push.autoSetupRemote is set to true" {
if [ "$SQL_ENGINE" = "remote-engine" ]; then
skip "local config change required for test"
fi

cd repo1
dolt checkout -b other

run dolt push
[ "$status" -eq 1 ]
[[ "$output" =~ "The current branch other has no upstream branch." ]] || false
Expand All @@ -163,6 +182,10 @@ teardown() {
}

@test "push: push without --set-upstream persists when push.autoSetupRemote is set to all capital TRUE" {
if [ "$SQL_ENGINE" = "remote-engine" ]; then
skip "local config change required for test"
fi

cd repo1
dolt checkout -b other
run dolt push
Expand All @@ -186,6 +209,9 @@ teardown() {
dolt push origin main

cd ../repo1

setup_remote_server

run dolt push origin main
[ "$status" -eq 1 ]
[[ "$output" =~ "hint: Updates were rejected because the tip of your current branch is behind" ]] || false
Expand All @@ -195,34 +221,49 @@ teardown() {

@test "push: push to unknown remote" {
cd repo1

setup_remote_server

run dolt push unknown main
[ "$status" -eq 1 ]
[[ "$output" =~ "fatal: remote 'unknown' not found" ]] || false
}

@test "push: push unknown branch" {
cd repo1

setup_remote_server

run dolt push origin unknown
[ "$status" -eq 1 ]
[[ "$output" =~ "refspec not found: 'unknown'" ]] || false
}

@test "push: not specifying a branch throws an error" {
cd repo1

setup_remote_server

run dolt push -u origin
[ "$status" -eq 1 ]
[[ "$output" =~ "fatal: The current branch main has no upstream branch." ]] || false
}

@test "push: pushing empty branch does not panic" {
cd repo1

setup_remote_server

run dolt push origin ''
[ "$status" -eq 1 ]
[[ "$output" =~ "invalid ref spec: ''" ]] || false
}

@test "push: --silent suppresses progress message" {
cd repo1

setup_remote_server

run dolt push origin main --silent
[ "$status" -eq 0 ]
! [[ "$output" =~ "Uploading..." ]] || false
Expand Down

0 comments on commit f589ad0

Please sign in to comment.