mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-25 10:26:22 -06:00
Fix bad + more testing, safer type conversion
This commit is contained in:
@@ -203,17 +203,29 @@ func getSavedQueries(sqlCtx *sql.Context, queryist cli.Queryist) (map[string]str
|
||||
return nil, err
|
||||
}
|
||||
for _, row := range rows {
|
||||
queryName, err := row[2].(*val.TextStorage).Unwrap(sqlCtx)
|
||||
var queryName, queryStatement string
|
||||
queryName, err = getStringColAsString(sqlCtx, row[2])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
queryStatement, err := row[3].(*val.TextStorage).Unwrap(sqlCtx)
|
||||
queryStatement, err := getStringColAsString(sqlCtx, row[3])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
savedQueries[queryName] = queryStatement
|
||||
}
|
||||
}
|
||||
|
||||
return savedQueries, nil
|
||||
}
|
||||
|
||||
// The dolt_query_catalog system table returns *val.TextStorage types under certain situations,
|
||||
// so we use a special parser to get the correct string values
|
||||
func getStringColAsString(sqlCtx *sql.Context, tableValue interface{}) (string, error) {
|
||||
if ts, ok := tableValue.(*val.TextStorage); ok {
|
||||
return ts.Unwrap(sqlCtx)
|
||||
} else if str, ok := tableValue.(string); ok {
|
||||
return str, nil
|
||||
} else {
|
||||
return "", fmt.Errorf("unexpected type %T, was expecting string", tableValue)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,6 @@ teardown() {
|
||||
teardown_common
|
||||
}
|
||||
|
||||
skip_remote_engine() {
|
||||
if [ "$SQL_ENGINE" = "remote-engine" ]; then
|
||||
skip "session ctx in shell is not the same as session in server"
|
||||
fi
|
||||
}
|
||||
|
||||
get_commit_hash() {
|
||||
local logline=$(dolt log -n "$1")
|
||||
echo ${logline:12:32}
|
||||
@@ -355,9 +349,6 @@ EOF
|
||||
}
|
||||
|
||||
@test "ci: dolt ci view shows ci" {
|
||||
if [ "$SQL_ENGINE" = "remote-engine" ]; then
|
||||
skip "Dolt sql --save has not been migrated to be used with an active server"
|
||||
fi
|
||||
cat > workflow.yaml <<EOF
|
||||
name: workflow
|
||||
on:
|
||||
@@ -592,7 +583,8 @@ EOF
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" =~ "Running workflow: workflow" ]] || false
|
||||
[[ "$output" =~ "Step: should fail, bad table name - FAIL" ]] || false
|
||||
[[ "$output" =~ "Query error: table not found: invalid" ]] || false
|
||||
[[ "$output" =~ "Query error" ]] || false
|
||||
[[ "$output" =~ "table not found: invalid" ]] || false
|
||||
}
|
||||
|
||||
@test "ci: ci run fails on invalid workflow name" {
|
||||
@@ -600,11 +592,14 @@ EOF
|
||||
run dolt ci run "invalid"
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "workflow not found" ]] || false
|
||||
run dolt ci run
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "must specify workflow name" ]] || false
|
||||
}
|
||||
|
||||
@test "ci: ci run fails on invalid query name" {
|
||||
cat > workflow.yaml <<EOF
|
||||
name: workflow5
|
||||
name: workflow
|
||||
on:
|
||||
push: {}
|
||||
jobs:
|
||||
@@ -620,6 +615,4 @@ EOF
|
||||
[[ "$output" =~ "Running workflow: workflow" ]] || false
|
||||
[[ "$output" =~ "Step: should fail, bad query name - FAIL" ]] || false
|
||||
[[ "$output" =~ "Could not find saved query: invalid query" ]] || false
|
||||
}
|
||||
|
||||
# test ci with workflow with invalid query name
|
||||
}
|
||||
Reference in New Issue
Block a user