mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-29 03:08:47 -06:00
chore: added test case for log_format
This commit is contained in:
@@ -123,7 +123,8 @@ func ConfigureServices(
|
||||
return err
|
||||
}
|
||||
logrus.SetLevel(level)
|
||||
switch serverConfig.LogFormat() {
|
||||
format := strings.ToLower(fmt.Sprintf("%v", serverConfig.LogFormat()))
|
||||
switch format {
|
||||
case "json":
|
||||
logrus.SetFormatter(&logrus.JSONFormatter{})
|
||||
default:
|
||||
|
||||
@@ -281,9 +281,10 @@ func ValidateConfig(config ServerConfig) error {
|
||||
if config.LogLevel().String() == "unknown" {
|
||||
return fmt.Errorf("loglevel is invalid: %v\n", string(config.LogLevel()))
|
||||
}
|
||||
if config.LogFormat() != "text" && config.LogFormat() != "json" {
|
||||
return fmt.Errorf("logformat is invalid: %v\n", config.LogFormat())
|
||||
}
|
||||
if strings.ToLower(fmt.Sprintf("%v", config.LogFormat())) != "text" &&
|
||||
strings.ToLower(fmt.Sprintf("%v", config.LogFormat())) != "json" {
|
||||
return fmt.Errorf("logformat is invalid: %v\n", config.LogFormat())
|
||||
}
|
||||
if config.RequireSecureTransport() && config.TLSCert() == "" && config.TLSKey() == "" {
|
||||
return fmt.Errorf("require_secure_transport can only be `true` when a tls_key and tls_cert are provided.")
|
||||
}
|
||||
|
||||
@@ -145,6 +145,32 @@ EOF
|
||||
dolt sql -q "show databases;"
|
||||
stop_sql_server
|
||||
}
|
||||
@test "sql-server: logformats are case insensitive" {
|
||||
# assert that logformat on command line is not case sensitive
|
||||
cd repo1
|
||||
PORT=$( definePORT )
|
||||
dolt sql-server --logformat jSon --port=$PORT --socket "dolt.$PORT.sock" > log.txt 2>&1 &
|
||||
SERVER_PID=$!
|
||||
wait_for_connection $PORT 8500
|
||||
dolt sql -q "show databases;"
|
||||
stop_sql_server
|
||||
|
||||
# assert that logformat in yaml config is not case sensitive
|
||||
cat >config.yml <<EOF
|
||||
log_format: teXt
|
||||
behavior:
|
||||
disable_client_multi_statements: true
|
||||
listener:
|
||||
host: "0.0.0.0"
|
||||
port: $PORT
|
||||
EOF
|
||||
dolt sql-server --config ./config.yml --socket "dolt.$PORT.sock" &
|
||||
SERVER_PID=$!
|
||||
wait_for_connection $PORT 8500
|
||||
dolt sql -q "show databases;"
|
||||
stop_sql_server
|
||||
}
|
||||
|
||||
|
||||
@test "sql-server: server assumes existing user" {
|
||||
cd repo1
|
||||
|
||||
Reference in New Issue
Block a user