From 1096cef1fa0d18e4d281df890502857e9a91b76b Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Tue, 10 Aug 2021 13:36:30 -0700 Subject: [PATCH 1/2] Added a test for git config and HOME env var --- integration-tests/bats/config-home.bats | 77 +++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 integration-tests/bats/config-home.bats diff --git a/integration-tests/bats/config-home.bats b/integration-tests/bats/config-home.bats new file mode 100644 index 0000000000..d4555c1995 --- /dev/null +++ b/integration-tests/bats/config-home.bats @@ -0,0 +1,77 @@ +#!/usr/bin/env bats + +# This file contains tests of the `dolt config` with the $HOME +# environment variable set. These can't use standard setup, because +# the DOLT_ROOT_PATH env var takes precedent over HOME, and we set +# that by default. + +load helper/windows-compat + +if [ -z "$BATS_TMPDIR" ]; then + export BATS_TMPDIR=$HOME/batstmp/ + mkdir $BATS_TMPDIR +fi + +setup_no_dolt_init() { + export PATH=$PATH:~/go/bin + cd $BATS_TMPDIR + # Append the directory name with the pid of the calling process so + # multiple tests can be run in parallel on the same machine + mkdir "dolt-repo-$$" + cd "dolt-repo-$$" +} + +setup() { + setup_no_dolt_init + mkdir $BATS_TMPDIR/config-test$$ + cd $BATS_TMPDIR/dolt-repo-$$ +} + +teardown() { + teardown_common + rm -rf "$BATS_TMPDIR/config-test$$" +} + +@test "config: different HOME vars" { + mkdir "$BATS_TMPDIR/config-test$$/homeA" + HOME="$BATS_TMPDIR/config-test$$/homeA" + + HOME=$HOME dolt config --global --add metrics.disabled true > /dev/null 2>&1 + HOME=$HOME run dolt config --global --add test testA + [ "$status" -eq 0 ] + [[ "$output" =~ "Config successfully updated" ]] || false + HOME=$HOME run dolt config --list + [ "$status" -eq 0 ] + [[ "$output" =~ "test = testA" ]] || false + HOME=$HOME run dolt config --get test + [ "$status" -eq 0 ] + [ "$output" = "testA" ] + + mkdir "$BATS_TMPDIR/config-test$$/homeB" + HOME="$BATS_TMPDIR/config-test$$/homeB" + + HOME=$HOME dolt config --global --add metrics.disabled true > /dev/null 2>&1 + HOME=$HOME run dolt config --global --add test testB + [ "$status" -eq 0 ] + [[ "$output" =~ "Config successfully updated" ]] || false + HOME=$HOME run dolt config --list + [ "$status" -eq 0 ] + [[ "$output" =~ "test = testB" ]] || false + [[ ! "$output" =~ "test = testA" ]] || false + HOME=$HOME run dolt config --get test + [ "$status" -eq 0 ] + [ "$output" = "testB" ] + + HOME="$BATS_TMPDIR/config-test$$/homeA" + + HOME=$HOME run dolt config --global --add test testA + [ "$status" -eq 0 ] + [[ "$output" =~ "Config successfully updated" ]] || false + HOME=$HOME run dolt config --list + [ "$status" -eq 0 ] + [[ "$output" =~ "test = testA" ]] || false + [[ ! "$output" =~ "test = testB" ]] || false + HOME=$HOME run dolt config --get test + [ "$status" -eq 0 ] + [ "$output" = "testA" ] +} From 4e8e3b96ca5163ff8512d9eb182b51db5b138ded Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Wed, 11 Aug 2021 10:57:05 -0700 Subject: [PATCH 2/2] Fixed bad test name --- integration-tests/bats/config-home.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/bats/config-home.bats b/integration-tests/bats/config-home.bats index d4555c1995..bce68fc597 100644 --- a/integration-tests/bats/config-home.bats +++ b/integration-tests/bats/config-home.bats @@ -32,7 +32,7 @@ teardown() { rm -rf "$BATS_TMPDIR/config-test$$" } -@test "config: different HOME vars" { +@test "config-home: different HOME vars" { mkdir "$BATS_TMPDIR/config-test$$/homeA" HOME="$BATS_TMPDIR/config-test$$/homeA"