@@ -36,47 +36,67 @@ func TestDumpCmd(t *testing.T) {
3636 Targets : []storage.Storage {file .New (* fileTargetURL )},
3737 MaxAllowedPacket : defaultMaxAllowedPacket ,
3838 Compressor : & compression.GzipCompressor {},
39- DBConn : database.Connection {Host : "abc" },
39+ DBConn : database.Connection {Host : "abc" , Port : defaultPort },
4040 }, core.TimerOptions {Frequency : defaultFrequency , Begin : defaultBegin }, nil },
4141 {"file URL with prune" , []string {"--server" , "abc" , "--target" , "file:///foo/bar" , "--retention" , "1h" }, "" , false , core.DumpOptions {
4242 Targets : []storage.Storage {file .New (* fileTargetURL )},
4343 MaxAllowedPacket : defaultMaxAllowedPacket ,
4444 Compressor : & compression.GzipCompressor {},
45- DBConn : database.Connection {Host : "abc" },
45+ DBConn : database.Connection {Host : "abc" , Port : defaultPort },
4646 }, core.TimerOptions {Frequency : defaultFrequency , Begin : defaultBegin }, & core.PruneOptions {Targets : []storage.Storage {file .New (* fileTargetURL )}, Retention : "1h" }},
4747
48+ // database name and port
49+ {"database explicit name with default port" , []string {"--server" , "abc" , "--target" , "file:///foo/bar" }, "" , false , core.DumpOptions {
50+ Targets : []storage.Storage {file .New (* fileTargetURL )},
51+ MaxAllowedPacket : defaultMaxAllowedPacket ,
52+ Compressor : & compression.GzipCompressor {},
53+ DBConn : database.Connection {Host : "abc" , Port : defaultPort },
54+ }, core.TimerOptions {Frequency : defaultFrequency , Begin : defaultBegin }, nil },
55+ {"database explicit name with explicit port" , []string {"--server" , "abc" , "--port" , "3307" , "--target" , "file:///foo/bar" }, "" , false , core.DumpOptions {
56+ Targets : []storage.Storage {file .New (* fileTargetURL )},
57+ MaxAllowedPacket : defaultMaxAllowedPacket ,
58+ Compressor : & compression.GzipCompressor {},
59+ DBConn : database.Connection {Host : "abc" , Port : 3307 },
60+ }, core.TimerOptions {Frequency : defaultFrequency , Begin : defaultBegin }, nil },
61+
4862 // config file
4963 {"config file" , []string {"--config-file" , "testdata/config.yml" }, "" , false , core.DumpOptions {
5064 Targets : []storage.Storage {file .New (* fileTargetURL )},
5165 MaxAllowedPacket : defaultMaxAllowedPacket ,
5266 Compressor : & compression.GzipCompressor {},
5367 DBConn : database.Connection {Host : "abcd" , Port : 3306 , User : "user2" , Pass : "xxxx2" },
5468 }, core.TimerOptions {Frequency : defaultFrequency , Begin : defaultBegin }, & core.PruneOptions {Targets : []storage.Storage {file .New (* fileTargetURL )}, Retention : "1h" }},
69+ {"config file with port override" , []string {"--config-file" , "testdata/config.yml" , "--port" , "3307" }, "" , false , core.DumpOptions {
70+ Targets : []storage.Storage {file .New (* fileTargetURL )},
71+ MaxAllowedPacket : defaultMaxAllowedPacket ,
72+ Compressor : & compression.GzipCompressor {},
73+ DBConn : database.Connection {Host : "abcd" , Port : 3307 , User : "user2" , Pass : "xxxx2" },
74+ }, core.TimerOptions {Frequency : defaultFrequency , Begin : defaultBegin }, & core.PruneOptions {Targets : []storage.Storage {file .New (* fileTargetURL )}, Retention : "1h" }},
5575
5676 // timer options
5777 {"once flag" , []string {"--server" , "abc" , "--target" , "file:///foo/bar" , "--once" }, "" , false , core.DumpOptions {
5878 Targets : []storage.Storage {file .New (* fileTargetURL )},
5979 MaxAllowedPacket : defaultMaxAllowedPacket ,
6080 Compressor : & compression.GzipCompressor {},
61- DBConn : database.Connection {Host : "abc" },
81+ DBConn : database.Connection {Host : "abc" , Port : defaultPort },
6282 }, core.TimerOptions {Once : true , Frequency : defaultFrequency , Begin : defaultBegin }, nil },
6383 {"cron flag" , []string {"--server" , "abc" , "--target" , "file:///foo/bar" , "--cron" , "0 0 * * *" }, "" , false , core.DumpOptions {
6484 Targets : []storage.Storage {file .New (* fileTargetURL )},
6585 MaxAllowedPacket : defaultMaxAllowedPacket ,
6686 Compressor : & compression.GzipCompressor {},
67- DBConn : database.Connection {Host : "abc" },
87+ DBConn : database.Connection {Host : "abc" , Port : defaultPort },
6888 }, core.TimerOptions {Frequency : defaultFrequency , Begin : defaultBegin , Cron : "0 0 * * *" }, nil },
6989 {"begin flag" , []string {"--server" , "abc" , "--target" , "file:///foo/bar" , "--begin" , "1234" }, "" , false , core.DumpOptions {
7090 Targets : []storage.Storage {file .New (* fileTargetURL )},
7191 MaxAllowedPacket : defaultMaxAllowedPacket ,
7292 Compressor : & compression.GzipCompressor {},
73- DBConn : database.Connection {Host : "abc" },
93+ DBConn : database.Connection {Host : "abc" , Port : defaultPort },
7494 }, core.TimerOptions {Frequency : defaultFrequency , Begin : "1234" }, nil },
7595 {"frequency flag" , []string {"--server" , "abc" , "--target" , "file:///foo/bar" , "--frequency" , "10" }, "" , false , core.DumpOptions {
7696 Targets : []storage.Storage {file .New (* fileTargetURL )},
7797 MaxAllowedPacket : defaultMaxAllowedPacket ,
7898 Compressor : & compression.GzipCompressor {},
79- DBConn : database.Connection {Host : "abc" },
99+ DBConn : database.Connection {Host : "abc" , Port : defaultPort },
80100 }, core.TimerOptions {Frequency : 10 , Begin : defaultBegin }, nil },
81101 {"incompatible flags: once/cron" , []string {"--server" , "abc" , "--target" , "file:///foo/bar" , "--once" , "--cron" , "0 0 * * *" }, "" , true , core.DumpOptions {}, core.TimerOptions {}, nil },
82102 {"incompatible flags: once/begin" , []string {"--server" , "abc" , "--target" , "file:///foo/bar" , "--once" , "--begin" , "1234" }, "" , true , core.DumpOptions {}, core.TimerOptions {}, nil },
0 commit comments