Skip to content

Commit

Permalink
go/cmd/dolt/commands: Declare bankruptcy on signed commit test for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
reltuk committed Jan 31, 2025
1 parent ff7aebb commit 29cb66e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions go/cmd/dolt/commands/signed_commits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down Expand Up @@ -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",
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 29cb66e

Please sign in to comment.