Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix and unit test #266

Merged
merged 4 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func Sql(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEn
if err != nil {
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
}
err = runShell(ctx, se, nil)
err = runShell(ctx, se, dEnv)
if err != nil {
return HandleVErrAndExitCode(errhand.BuildDError("unable to start shell").AddCause(err).Build(), usage)
}
Expand Down
19 changes: 19 additions & 0 deletions go/cmd/dolt/commands/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ package commands

import (
"context"
"os"
"testing"
"time"

"github.com/google/uuid"
"github.com/stretchr/testify/assert"
Expand All @@ -40,6 +42,23 @@ import (

var tableName = "people"

// Smoke test: Console opens and exits
func TestSqlConsole(t *testing.T) {
t.Run("SQL console opens and exits", func(t *testing.T) {
dEnv := createEnvWithSeedData(t)
args := []string{}
commandStr := "dolt sql"

go func() {
time.Sleep(1 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to fail for some stupid reason on Jenkins eventually when it takes longer than a second. You might try adding a callback parameter to the Sql command that fires once it's ready to begin receiving input. It's gross, but also fault tolerant. Worth seeing how it looks anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason the test doesn't actually need to read exit from STDIN in order the close the console. The console just closes without waiting for input. I removed the coroutine altogether

_, _ = os.Stdin.WriteString("exit")
}()
result := Sql(context.TODO(), commandStr, args, dEnv)
assert.Equal(t, 0, result)
})

}

// Smoke tests, values are printed to console
func TestSqlSelect(t *testing.T) {
tests := []struct {
Expand Down