Skip to content

Commit

Permalink
fix duplicate dbconn variable
Browse files Browse the repository at this point in the history
Signed-off-by: Avi Deitcher <[email protected]>
  • Loading branch information
deitch committed Jan 7, 2024
1 parent 86e1d27 commit ed63b6f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func dumpCmd(execs execs) (*cobra.Command, error) {
return fmt.Errorf("failure to get compression '%s': %v", compressionAlgo, err)
}
}

dumpOpts := core.DumpOptions{
Targets: targets,
Safechars: safechars,
Expand Down
5 changes: 4 additions & 1 deletion cmd/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/databacker/mysql-backup/pkg/compression"
"github.com/databacker/mysql-backup/pkg/core"
"github.com/databacker/mysql-backup/pkg/database"
"github.com/databacker/mysql-backup/pkg/storage"
"github.com/databacker/mysql-backup/pkg/storage/file"
"github.com/go-test/deep"
Expand All @@ -26,16 +27,18 @@ func TestDumpCmd(t *testing.T) {
expectedTimerOptions core.TimerOptions
}{
{"missing server and target options", []string{""}, "", true, core.DumpOptions{}, core.TimerOptions{}},
{"invalid target URL", []string{"--server", "abc", "--target", "def"}, "", true, core.DumpOptions{}, core.TimerOptions{}},
{"invalid target URL", []string{"--server", "abc", "--target", "def"}, "", true, core.DumpOptions{DBConn: database.Connection{Host: "abc"}}, core.TimerOptions{}},
{"file URL", []string{"--server", "abc", "--target", "file:///foo/bar"}, "", false, core.DumpOptions{
Targets: []storage.Storage{file.New(*fileTargetURL)},
MaxAllowedPacket: defaultMaxAllowedPacket,
Compressor: &compression.GzipCompressor{},
DBConn: database.Connection{Host: "abc"},
}, core.TimerOptions{Frequency: defaultFrequency, Begin: defaultBegin}},
{"config file", []string{"--config-file", "testdata/config.yml"}, "", false, core.DumpOptions{
Targets: []storage.Storage{file.New(*fileTargetURL)},
MaxAllowedPacket: defaultMaxAllowedPacket,
Compressor: &compression.GzipCompressor{},
DBConn: database.Connection{Host: "abc", Port: 3306, User: "user", Pass: "xxxx"},
}, core.TimerOptions{Frequency: defaultFrequency, Begin: defaultBegin}},
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func TestRestoreCmd(t *testing.T) {
expectedCompressor compression.Compressor
}{
{"missing server and target options", []string{""}, "", true, nil, "", database.Connection{}, nil, &compression.GzipCompressor{}},
{"invalid target URL", []string{"--server", "abc", "--target", "def"}, "", true, nil, "", database.Connection{}, nil, &compression.GzipCompressor{}},
{"valid URL missing dump filename", []string{"--server", "abc", "--target", "file:///foo/bar"}, "", true, nil, "", database.Connection{}, nil, &compression.GzipCompressor{}},
{"valid file URL", []string{"--server", "abc", "--target", fileTarget, "filename.tgz"}, "", false, file.New(*fileTargetURL), "filename.tgz", database.Connection{}, map[string]string{}, &compression.GzipCompressor{}},
{"invalid target URL", []string{"--server", "abc", "--target", "def"}, "", true, nil, "", database.Connection{Host: "abc"}, nil, &compression.GzipCompressor{}},
{"valid URL missing dump filename", []string{"--server", "abc", "--target", "file:///foo/bar"}, "", true, nil, "", database.Connection{Host: "abc"}, nil, &compression.GzipCompressor{}},
{"valid file URL", []string{"--server", "abc", "--target", fileTarget, "filename.tgz"}, "", false, file.New(*fileTargetURL), "filename.tgz", database.Connection{Host: "abc"}, map[string]string{}, &compression.GzipCompressor{}},
}

for _, tt := range tests {
Expand Down
2 changes: 0 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ func rootCmd(execs execs) (*cobra.Command, error) {
// so we cannot use a single viper structure, as described above.

// set up database connection
var dbconn database.Connection

if configuration != nil {
if configuration.Database.Server != "" {
dbconn.Host = configuration.Database.Server
Expand Down

0 comments on commit ed63b6f

Please sign in to comment.