mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-25 00:54:51 -06:00
remove nonsense variables from config tests
This commit is contained in:
@@ -51,25 +51,25 @@ func TestConfigAdd(t *testing.T) {
|
||||
Name: "local",
|
||||
CfgSet: localCfg,
|
||||
Scope: env.LocalConfig,
|
||||
Args: []string{"title", "senior dufus"},
|
||||
Args: []string{"user.name", "senior dufus"},
|
||||
},
|
||||
{
|
||||
Name: "global",
|
||||
CfgSet: globalCfg,
|
||||
Scope: env.GlobalConfig,
|
||||
Args: []string{"title", "senior dufus"},
|
||||
Args: []string{"user.name", "senior dufus"},
|
||||
},
|
||||
{
|
||||
Name: "default",
|
||||
CfgSet: &set.StrSet{},
|
||||
Scope: env.LocalConfig,
|
||||
Args: []string{"title", "senior dufus"},
|
||||
Args: []string{"user.name", "senior dufus"},
|
||||
},
|
||||
{
|
||||
Name: "multi error",
|
||||
CfgSet: multiCfg,
|
||||
Scope: env.LocalConfig,
|
||||
Args: []string{"title", "senior dufus"},
|
||||
Args: []string{"user.name", "senior dufus"},
|
||||
Code: 1,
|
||||
},
|
||||
{
|
||||
@@ -83,7 +83,7 @@ func TestConfigAdd(t *testing.T) {
|
||||
Name: "odd args",
|
||||
CfgSet: multiCfg,
|
||||
Scope: env.LocalConfig,
|
||||
Args: []string{"title"},
|
||||
Args: []string{"user.name"},
|
||||
Code: 1,
|
||||
},
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func TestConfigAdd(t *testing.T) {
|
||||
assert.Equal(t, tt.Code, resCode)
|
||||
|
||||
} else if cfg, ok := dEnv.Config.GetConfig(tt.Scope); ok {
|
||||
resVal := cfg.GetStringOrDefault("title", "")
|
||||
resVal := cfg.GetStringOrDefault("user.name", "")
|
||||
assert.Equal(t, "senior dufus", resVal)
|
||||
} else {
|
||||
t.Error("comparison config not found")
|
||||
@@ -280,12 +280,12 @@ func TestConfig(t *testing.T) {
|
||||
|
||||
// test setting global config with --add
|
||||
configCmd := ConfigCmd{}
|
||||
ret := configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "name", "bheni"}, dEnv, nil)
|
||||
ret += configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "title", "dufus"}, dEnv, nil)
|
||||
ret := configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "user.name", "bheni"}, dEnv, nil)
|
||||
ret += configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "user.email", "dufus@example.com"}, dEnv, nil)
|
||||
|
||||
expectedGlobal := map[string]string{
|
||||
"name": "bheni",
|
||||
"title": "dufus",
|
||||
"user.name": "bheni",
|
||||
"user.email": "dufus@example.com",
|
||||
}
|
||||
|
||||
if ret != 0 {
|
||||
@@ -295,11 +295,11 @@ func TestConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
// test setting global config with --set
|
||||
ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--set", "name", "steph"}, dEnv, nil)
|
||||
ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--set", "user.name", "steph"}, dEnv, nil)
|
||||
|
||||
expectedGlobal = map[string]string{
|
||||
"name": "steph",
|
||||
"title": "dufus",
|
||||
"user.name": "steph",
|
||||
"user.email": "dufus@example.com",
|
||||
}
|
||||
|
||||
if ret != 0 {
|
||||
@@ -309,40 +309,40 @@ func TestConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
// test setting local config with --add
|
||||
ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--add", "title", "senior dufus"}, dEnv, nil)
|
||||
ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--add", "user.name", "senior dufus"}, dEnv, nil)
|
||||
|
||||
expectedLocal := map[string]string{
|
||||
"title": "senior dufus",
|
||||
"user.name": "senior dufus",
|
||||
}
|
||||
|
||||
if ret != 0 {
|
||||
t.Error("Failed to set local config")
|
||||
} else if cfg, ok := dEnv.Config.GetConfig(env.LocalConfig); !ok || !config.Equals(cfg, expectedLocal) {
|
||||
t.Error("config -add did not yield expected local results")
|
||||
} else if val, err := cfg.GetString("title"); err != nil || val != "senior dufus" {
|
||||
t.Error("Unexpected value of \"title\" retrieved from the config hierarchy")
|
||||
} else if val, err := cfg.GetString("user.name"); err != nil || val != "senior dufus" {
|
||||
t.Error("Unexpected value of \"user.name\" retrieved from the config hierarchy")
|
||||
}
|
||||
|
||||
// test setting local config with --set
|
||||
ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--set", "name", "steph"}, dEnv, nil)
|
||||
ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--set", "user.email", "dufus@example.com"}, dEnv, nil)
|
||||
|
||||
expectedLocal = map[string]string{
|
||||
"name": "steph",
|
||||
"title": "senior dufus",
|
||||
"user.name": "senior dufus",
|
||||
"user.email": "dufus@example.com",
|
||||
}
|
||||
|
||||
if ret != 0 {
|
||||
t.Error("Failed to set local config")
|
||||
} else if cfg, ok := dEnv.Config.GetConfig(env.LocalConfig); !ok || !config.Equals(cfg, expectedLocal) {
|
||||
t.Error("config -set did not yield expected local results")
|
||||
} else if val, err := cfg.GetString("name"); err != nil || val != "steph" {
|
||||
t.Error("Unexpected value of \"name\" retrieved from the config hierarchy")
|
||||
} else if val, err := cfg.GetString("user.email"); err != nil || val != "dufus@example.com" {
|
||||
t.Error("Unexpected value of \"user.email\" retrieved from the config hierarchy")
|
||||
}
|
||||
|
||||
ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--unset", "name"}, dEnv, nil)
|
||||
ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--unset", "user.name"}, dEnv, nil)
|
||||
|
||||
expectedGlobal = map[string]string{
|
||||
"title": "dufus",
|
||||
"user.email": "dufus@example.com",
|
||||
}
|
||||
|
||||
if ret != 0 {
|
||||
@@ -351,7 +351,7 @@ func TestConfig(t *testing.T) {
|
||||
t.Error("config -add did not yield expected global results")
|
||||
}
|
||||
|
||||
expectedGlobal = map[string]string{"title": "dufus"}
|
||||
expectedGlobal = map[string]string{"user.email": "dufus@example.com"}
|
||||
globalProperties := map[string]string{}
|
||||
ret = listOperation(dEnv, globalCfg, []string{}, func() {}, func(k string, v string) {
|
||||
globalProperties[k] = v
|
||||
@@ -363,7 +363,7 @@ func TestConfig(t *testing.T) {
|
||||
t.Error("listOperation did not yield expected global results")
|
||||
}
|
||||
|
||||
expectedLocal = map[string]string{"name": "steph", "title": "senior dufus"}
|
||||
expectedLocal = map[string]string{"user.name": "senior dufus", "user.email": "dufus@example.com"}
|
||||
localProperties := map[string]string{}
|
||||
ret = listOperation(dEnv, localCfg, []string{}, func() {}, func(k string, v string) {
|
||||
localProperties[k] = v
|
||||
@@ -375,8 +375,8 @@ func TestConfig(t *testing.T) {
|
||||
t.Error("listOperation did not yield expected local results")
|
||||
}
|
||||
|
||||
ret = getOperation(dEnv, globalCfg, []string{"title"}, func(k string, v *string) {
|
||||
if v == nil || *v != "dufus" {
|
||||
ret = getOperation(dEnv, globalCfg, []string{"user.email"}, func(k string, v *string) {
|
||||
if v == nil || *v != "dufus@example.com" {
|
||||
t.Error("Failed to get expected value for title.")
|
||||
}
|
||||
})
|
||||
@@ -385,9 +385,9 @@ func TestConfig(t *testing.T) {
|
||||
t.Error("get operation failed")
|
||||
}
|
||||
|
||||
ret = getOperation(dEnv, globalCfg, []string{"name"}, func(k string, v *string) {
|
||||
ret = getOperation(dEnv, globalCfg, []string{"user.name"}, func(k string, v *string) {
|
||||
if v != nil {
|
||||
t.Error("Failed to get expected value for \"name\" which should not be set in the config.")
|
||||
t.Error("Failed to get expected value for \"user.name\" which should not be set in the config.")
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -37,41 +37,41 @@ teardown() {
|
||||
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
|
||||
HOME=$HOME run dolt config --global --add user.name "Your Name"
|
||||
[ "$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
|
||||
[[ "$output" =~ "user.name = Your Name" ]] || false
|
||||
HOME=$HOME run dolt config --get user.name
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "testA" ]
|
||||
[ "$output" = "Your Name" ]
|
||||
|
||||
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
|
||||
HOME=$HOME run dolt config --global --add core.editor foo
|
||||
[ "$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
|
||||
[[ "$output" =~ "core.editor = foo" ]] || false
|
||||
[[ ! "$output" =~ "user.name = Your Name" ]] || false
|
||||
HOME=$HOME run dolt config --get core.editor
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "testB" ]
|
||||
[ "$output" = "foo" ]
|
||||
|
||||
HOME="$BATS_TMPDIR/config-test$$/homeA"
|
||||
|
||||
HOME=$HOME run dolt config --global --add test testA
|
||||
HOME=$HOME run dolt config --global --add user.email "you@example.com"
|
||||
[ "$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
|
||||
[[ "$output" =~ "user.email = you@example.com" ]] || false
|
||||
[[ ! "$output" =~ "core.editor = foo" ]] || false
|
||||
HOME=$HOME run dolt config --get user.email
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "testA" ]
|
||||
[ "$output" = "you@example.com" ]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user