mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-08 02:36:27 -05:00
Couple small bug fixes and first bats test
This commit is contained in:
@@ -58,7 +58,7 @@ func (fact FileFactory) PrepareDB(ctx context.Context, nbf *types.NomsBinFormat,
|
||||
info, err := os.Stat(path)
|
||||
|
||||
if os.IsNotExist(err) {
|
||||
return os.MkdirAll(path, os.ModeDir)
|
||||
return os.MkdirAll(path, os.ModePerm)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -71,7 +71,7 @@ func GetCommitHooks(ctx context.Context, bThreads *sql.BackgroundThreads, dEnv *
|
||||
postCommitHooks := make([]doltdb.CommitHook, 0)
|
||||
|
||||
if hook, err := getPushOnWriteHook(ctx, bThreads, dEnv, logger); err != nil {
|
||||
path, err := dEnv.FS.Abs(".")
|
||||
path, _ := dEnv.FS.Abs(".")
|
||||
err = fmt.Errorf("failure loading hook for database at %s; %w", path, err)
|
||||
if SkipReplicationWarnings() {
|
||||
postCommitHooks = append(postCommitHooks, doltdb.NewLogHook([]byte(err.Error()+"\n")))
|
||||
|
||||
@@ -80,6 +80,7 @@ teardown() {
|
||||
|
||||
clone_helper $TMPDIRS
|
||||
run dolt sql --data-dir=dbs2 -b -q "use repo1; show tables" -r csv
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 4 ]
|
||||
[[ "$output" =~ "t1" ]] || false
|
||||
@@ -101,6 +102,34 @@ teardown() {
|
||||
[[ ! "$output" =~ "t2" ]] || false
|
||||
}
|
||||
|
||||
@test "replication-multidb: push newly created database" {
|
||||
dolt config --global --add sqlserver.global.dolt_replicate_to_remote remote1
|
||||
dolt sql -q "set @@persist.dolt_replication_remote_url_template = 'file://$TMPDIRS/rem1/%s'"
|
||||
|
||||
dolt sql --data-dir=dbs1 <<SQL
|
||||
create database newdb;
|
||||
use newdb;
|
||||
create table new_table (b int primary key);
|
||||
call dolt_add('.');
|
||||
call dolt_commit('-am', 'new table');
|
||||
SQL
|
||||
|
||||
mkdir -p "${TMPDIRS}/dbs2"
|
||||
cd $TMPDIRS
|
||||
pwd
|
||||
dolt clone "file://./rem1/newdb" "dbs2/newdb"
|
||||
|
||||
# this is a hack: we have to change our persisted global server
|
||||
# vars for the sql command to work on the replica TODO: fix this
|
||||
# mess
|
||||
dolt config --global --unset sqlserver.global.dolt_replicate_to_remote
|
||||
|
||||
run dolt sql --data-dir=dbs2 -q "use newdb; show tables" -r csv
|
||||
[ $status -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 3 ]
|
||||
[[ "$output" =~ "new_table" ]] || false
|
||||
}
|
||||
|
||||
@test "replication-multidb: pull on read" {
|
||||
push_helper $TMPDIRS
|
||||
dolt sql --data-dir=dbs1 -b -q "use repo1; create table t1 (a int primary key)"
|
||||
|
||||
Reference in New Issue
Block a user