-
-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/cmd/dolt/commands: Declare bankruptcy on signed commit test for now.
- Loading branch information
Showing
1 changed file
with
7 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,6 @@ import ( | |
"testing" | ||
|
||
"github.com/dolthub/dolt/go/cmd/dolt/cli" | ||
"github.com/dolthub/dolt/go/libraries/doltcore/dbfactory" | ||
"github.com/dolthub/dolt/go/libraries/doltcore/env" | ||
"github.com/dolthub/dolt/go/libraries/utils/argparser" | ||
"github.com/dolthub/dolt/go/libraries/utils/config" | ||
|
@@ -46,9 +45,10 @@ func importKey(t *testing.T, ctx context.Context) { | |
} | ||
|
||
func setupTestDB(t *testing.T, ctx context.Context, fs filesys.Filesys) string { | ||
dir := t.TempDir() | ||
dir, err := os.MkdirTemp(os.TempDir(), "signed_commits") | ||
require.NoError(t, err) | ||
dbDir := filepath.Join(dir, "db") | ||
err := filesys.CopyDir("testdata/signed_commits/db/", dbDir, fs) | ||
err = filesys.CopyDir("testdata/signed_commits/db/", dbDir, fs) | ||
require.NoError(t, err) | ||
|
||
log.Println(dbDir) | ||
|
@@ -79,9 +79,6 @@ func TestSignAndVerifyCommit(t *testing.T) { | |
ctx := context.Background() | ||
importKey(t, ctx) | ||
dbDir := setupTestDB(t, ctx, filesys.LocalFS) | ||
t.Cleanup(func() { | ||
dbfactory.CloseAllLocalDatabases() | ||
}) | ||
|
||
global := map[string]string{ | ||
"user.name": "First Last", | ||
|
@@ -93,7 +90,7 @@ func TestSignAndVerifyCommit(t *testing.T) { | |
apr, err := cli.CreateCommitArgParser().Parse(test.commitArgs) | ||
require.NoError(t, err) | ||
|
||
_, err = execCommand(ctx, t, dbDir, CommitCmd{}, test.commitArgs, apr, map[string]string{}, global) | ||
_, err = execCommand(ctx, dbDir, CommitCmd{}, test.commitArgs, apr, map[string]string{}, global) | ||
|
||
if test.expectErr { | ||
require.Error(t, err) | ||
|
@@ -106,14 +103,14 @@ func TestSignAndVerifyCommit(t *testing.T) { | |
apr, err = cli.CreateLogArgParser(false).Parse(args) | ||
require.NoError(t, err) | ||
|
||
logOutput, err := execCommand(ctx, t, dbDir, LogCmd{}, args, apr, map[string]string{}, global) | ||
logOutput, err := execCommand(ctx, dbDir, LogCmd{}, args, apr, map[string]string{}, global) | ||
require.NoError(t, err) | ||
require.Contains(t, logOutput, "Good signature from \"Test User <[email protected]>\"") | ||
}) | ||
} | ||
} | ||
|
||
func execCommand(ctx context.Context, t *testing.T, wd string, cmd cli.Command, args []string, apr *argparser.ArgParseResults, local, global map[string]string) (output string, err error) { | ||
func execCommand(ctx context.Context, wd string, cmd cli.Command, args []string, apr *argparser.ArgParseResults, local, global map[string]string) (output string, err error) { | ||
err = os.Chdir(wd) | ||
if err != nil { | ||
err = fmt.Errorf("error changing directory to %s: %w", wd, err) | ||
|
@@ -160,7 +157,7 @@ func execCommand(ctx context.Context, t *testing.T, wd string, cmd cli.Command, | |
|
||
initialOut := os.Stdout | ||
initialErr := os.Stderr | ||
f, err := os.CreateTemp(t.TempDir(), "signed-commit-test-*") | ||
f, err := os.CreateTemp(os.TempDir(), "signed-commit-test-*") | ||
if err != nil { | ||
err = fmt.Errorf("error creating temp file: %w", err) | ||
return | ||
|