-
-
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.
Merge pull request #8783 from dolthub/nicktobey/lazy-load
Avoid loading DB for commands where it's not necessary.
- Loading branch information
Showing
112 changed files
with
846 additions
and
687 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
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
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -67,15 +67,16 @@ func TestInit(t *testing.T) { | |
|
||
for _, test := range tests { | ||
t.Run(test.Name, func(t *testing.T) { | ||
ctx := context.Background() | ||
dEnv := createUninitializedEnv() | ||
gCfg, _ := dEnv.Config.GetConfig(env.GlobalConfig) | ||
gCfg.SetStrings(test.GlobalConfig) | ||
apr := argparser.ArgParseResults{} | ||
latebind := func(ctx context.Context) (cli.Queryist, *sql.Context, func(), error) { return nil, nil, func() {}, nil } | ||
cliCtx, _ := cli.NewCliContext(&apr, dEnv.Config, dEnv.FS, latebind) | ||
|
||
result := InitCmd{}.Exec(context.Background(), "dolt init", test.Args, dEnv, cliCtx) | ||
defer dEnv.DoltDB.Close() | ||
result := InitCmd{}.Exec(ctx, "dolt init", test.Args, dEnv, cliCtx) | ||
defer dEnv.DoltDB(ctx).Close() | ||
|
||
require.Equalf(t, test.ExpectSuccess, result == 0, "- Expected success: %t; result: %t;", test.ExpectSuccess, result == 0) | ||
|
||
|
@@ -92,12 +93,13 @@ func TestInit(t *testing.T) { | |
} | ||
|
||
func TestInitTwice(t *testing.T) { | ||
ctx := context.Background() | ||
dEnv := createUninitializedEnv() | ||
result := InitCmd{}.Exec(context.Background(), "dolt init", []string{"-name", "Bill Billerson", "-email", "[email protected]"}, dEnv, nil) | ||
result := InitCmd{}.Exec(ctx, "dolt init", []string{"-name", "Bill Billerson", "-email", "[email protected]"}, dEnv, nil) | ||
require.True(t, result == 0, "First init should succeed") | ||
defer dEnv.DoltDB.Close() | ||
defer dEnv.DoltDB(ctx).Close() | ||
|
||
result = InitCmd{}.Exec(context.Background(), "dolt init", []string{"-name", "Bill Billerson", "-email", "[email protected]"}, dEnv, nil) | ||
result = InitCmd{}.Exec(ctx, "dolt init", []string{"-name", "Bill Billerson", "-email", "[email protected]"}, dEnv, nil) | ||
require.True(t, result != 0, "Second init should fail") | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -32,16 +32,17 @@ import ( | |
) | ||
|
||
func TestLog(t *testing.T) { | ||
ctx := context.Background() | ||
dEnv := createUninitializedEnv() | ||
err := dEnv.InitRepo(context.Background(), types.Format_Default, "Bill Billerson", "[email protected]", env.DefaultInitBranch) | ||
defer dEnv.DoltDB.Close() | ||
err := dEnv.InitRepo(ctx, types.Format_Default, "Bill Billerson", "[email protected]", env.DefaultInitBranch) | ||
defer dEnv.DoltDB(ctx).Close() | ||
|
||
if err != nil { | ||
t.Error("Failed to init repo") | ||
} | ||
|
||
cs, _ := doltdb.NewCommitSpec(env.DefaultInitBranch) | ||
opt, _ := dEnv.DoltDB.Resolve(context.Background(), cs, nil) | ||
opt, _ := dEnv.DoltDB(ctx).Resolve(context.Background(), cs, nil) | ||
commit, _ := opt.ToCommit() | ||
|
||
meta, _ := commit.GetCommitMeta(context.Background()) | ||
|
@@ -53,16 +54,17 @@ func TestLogSigterm(t *testing.T) { | |
t.Skip("Skipping test as function used is not supported on Windows") | ||
} | ||
|
||
ctx := context.Background() | ||
dEnv := createUninitializedEnv() | ||
err := dEnv.InitRepo(context.Background(), types.Format_Default, "Bill Billerson", "[email protected]", env.DefaultInitBranch) | ||
defer dEnv.DoltDB.Close() | ||
err := dEnv.InitRepo(ctx, types.Format_Default, "Bill Billerson", "[email protected]", env.DefaultInitBranch) | ||
defer dEnv.DoltDB(ctx).Close() | ||
|
||
if err != nil { | ||
t.Error("Failed to init repo") | ||
} | ||
|
||
cs, _ := doltdb.NewCommitSpec(env.DefaultInitBranch) | ||
optCmt, _ := dEnv.DoltDB.Resolve(context.Background(), cs, nil) | ||
optCmt, _ := dEnv.DoltDB(ctx).Resolve(context.Background(), cs, nil) | ||
commit, _ := optCmt.ToCommit() | ||
cMeta, _ := commit.GetCommitMeta(context.Background()) | ||
cHash, _ := commit.HashOf() | ||
|
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
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
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
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
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
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
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
Oops, something went wrong.