Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/testserver/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ func AddDefaultHandlers(server *Server) {
})

// SQL Statement Execution lifecycle. Tests program these by registering
// matchers via Server.HandleSQL / HandleSQLPattern (see statements.go).
// matchers via Server.HandleSQL (see statements.go).
// They live here, not in New, so they act as overridable defaults: a test
// that needs raw control over a SQL endpoint (malformed body, transport
// error, custom status) can register its own handler for the same pattern
Expand Down
7 changes: 0 additions & 7 deletions libs/testserver/statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"regexp"
"strconv"

"github.com/databricks/cli/libs/testserver/testsql"
Expand All @@ -17,12 +16,6 @@ func (s *Server) HandleSQL(statement string, fn func(testsql.Request) testsql.Re
s.sqlHandler.Handle(statement, fn)
}

// HandleSQLPattern registers a matcher that runs fn when re matches a submitted
// statement, passing the submatches through as Request.Match.
func (s *Server) HandleSQLPattern(re *regexp.Regexp, fn func(testsql.Request) testsql.Result) {
s.sqlHandler.HandlePattern(re, fn)
}

// sqlExecuteStatement handles POST /api/2.0/sql/statements. A statement that
// terminates as FAILED comes back as HTTP 200 with state=FAILED; the engine
// builds that response and this HTTP layer is just transport.
Expand Down
16 changes: 0 additions & 16 deletions libs/testserver/statements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package testserver

import (
"encoding/json"
"regexp"
"testing"

"github.com/databricks/cli/libs/testserver/testsql"
Expand Down Expand Up @@ -34,18 +33,3 @@ func TestHandleSQL(t *testing.T) {
require.NotNil(t, resp.Result)
assert.Equal(t, [][]string{{"1"}}, resp.Result.DataArray)
}

func TestHandleSQLPattern(t *testing.T) {
server := New(t)
// A regex matcher echoes back a captured submatch, exercising both the
// HandleSQLPattern registration and Request.Match.
server.HandleSQLPattern(regexp.MustCompile(`^SELECT (\d+)$`), func(r testsql.Request) testsql.Result {
return testsql.Result{Columns: []string{"n"}, Rows: [][]string{{r.Match[1]}}}
})

resp := submitSQL(t, server, "SELECT 42")
require.NotNil(t, resp.Status)
assert.Equal(t, sql.StatementStateSucceeded, resp.Status.State)
require.NotNil(t, resp.Result)
assert.Equal(t, [][]string{{"42"}}, resp.Result.DataArray)
}
Loading