@@ -225,6 +225,8 @@ exclude = "exclude"
225225iexclude = "iexclude"
226226[profile.copy]
227227password-file = "key"
228+ [profile.dump]
229+ password-file = "key"
228230`
229231 profile , err := getProfile ("toml" , testConfig , "profile" , "" )
230232 if err != nil {
@@ -243,6 +245,7 @@ password-file = "key"
243245 assert .ElementsMatch (t , []string {"exclude" }, profile .Backup .Exclude )
244246 assert .ElementsMatch (t , []string {"iexclude" }, profile .Backup .Iexclude )
245247 assert .Equal (t , "/wd/key" , profile .Copy .PasswordFile )
248+ assert .Equal (t , []string {"/wd/key" }, profile .Dump ["password-file" ])
246249}
247250
248251func TestHostInProfile (t * testing.T ) {
@@ -284,6 +287,13 @@ func TestHostInAllSupportedSections(t *testing.T) {
284287 constants .CommandSnapshots ,
285288 constants .CommandMount ,
286289 constants .SectionConfigurationRetention ,
290+ constants .CommandCopy ,
291+ constants .CommandDump ,
292+ constants .CommandFind ,
293+ constants .CommandLs ,
294+ constants .CommandRestore ,
295+ constants .CommandStats ,
296+ constants .CommandTag ,
287297 }
288298
289299 assertHostIs := func (expectedHost []string , profile * Profile , section string ) {
@@ -712,6 +722,18 @@ other-flag-prune = true
712722other-flag-mount = true
713723[profile.copy]
714724other-flag-copy = true
725+ [profile.dump]
726+ other-flag-dump = true
727+ [profile.find]
728+ other-flag-find = true
729+ [profile.ls]
730+ other-flag-ls = true
731+ [profile.restore]
732+ other-flag-restore = true
733+ [profile.stats]
734+ other-flag-stats = true
735+ [profile.tag]
736+ other-flag-tag = true
715737` },
716738 {"json" , `
717739{
@@ -724,7 +746,13 @@ other-flag-copy = true
724746 "forget": {"other-flag-forget": true},
725747 "prune": {"other-flag-prune": true},
726748 "mount": {"other-flag-mount": true},
727- "copy": {"other-flag-copy": true}
749+ "copy": {"other-flag-copy": true},
750+ "dump": {"other-flag-dump": true},
751+ "find": {"other-flag-find": true},
752+ "ls": {"other-flag-ls": true},
753+ "restore": {"other-flag-restore": true},
754+ "stats": {"other-flag-stats": true},
755+ "tag": {"other-flag-tag": true}
728756 }
729757}` },
730758 {"yaml" , `---
@@ -746,6 +774,18 @@ profile:
746774 other-flag-mount: true
747775 copy:
748776 other-flag-copy: true
777+ dump:
778+ other-flag-dump: true
779+ find:
780+ other-flag-find: true
781+ ls:
782+ other-flag-ls: true
783+ restore:
784+ other-flag-restore: true
785+ stats:
786+ other-flag-stats: true
787+ tag:
788+ other-flag-tag: true
749789` },
750790 {"hcl" , `
751791"profile" = {
@@ -774,6 +814,24 @@ profile:
774814 copy = {
775815 other-flag-copy = true
776816 }
817+ dump = {
818+ other-flag-dump = true
819+ }
820+ find = {
821+ other-flag-find = true
822+ }
823+ ls = {
824+ other-flag-ls = true
825+ }
826+ restore = {
827+ other-flag-restore = true
828+ }
829+ stats = {
830+ other-flag-stats = true
831+ }
832+ tag = {
833+ other-flag-tag = true
834+ }
777835}
778836` },
779837 }
@@ -794,57 +852,49 @@ profile:
794852 require .NotNil (t , profile .Prune )
795853 require .NotNil (t , profile .Snapshots )
796854 require .NotNil (t , profile .Copy )
855+ require .NotNil (t , profile .Dump )
856+ require .NotNil (t , profile .Find )
857+ require .NotNil (t , profile .Ls )
858+ require .NotNil (t , profile .Restore )
859+ require .NotNil (t , profile .Stats )
860+ require .NotNil (t , profile .Tag )
797861
798862 flags := profile .GetCommonFlags ()
799863 assert .Equal (t , 1 , len (flags .ToMap ()))
800864 assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
801865
802- flags = profile .GetCommandFlags ("backup" )
803- assert .Equal (t , 2 , len (flags .ToMap ()))
804- assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
805- assert .ElementsMatch (t , []string {"backup" }, flags .ToMap ()["other-flag-backup" ])
806-
807866 flags = profile .GetRetentionFlags ()
808867 assert .Equal (t , 2 , len (flags .ToMap ()))
809868 assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
810869 _ , found := flags .ToMap ()["other-flag-retention" ]
811870 assert .True (t , found )
812871
813- flags = profile .GetCommandFlags ("snapshots" )
814- assert .Equal (t , 2 , len (flags .ToMap ()))
815- assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
816- _ , found = flags .ToMap ()["other-flag-snapshots" ]
817- assert .True (t , found )
818-
819- flags = profile .GetCommandFlags ("check" )
820- assert .Equal (t , 2 , len (flags .ToMap ()))
821- assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
822- _ , found = flags .ToMap ()["other-flag-check" ]
823- assert .True (t , found )
824-
825- flags = profile .GetCommandFlags ("forget" )
826- assert .Equal (t , 2 , len (flags .ToMap ()))
827- assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
828- _ , found = flags .ToMap ()["other-flag-forget" ]
829- assert .True (t , found )
830-
831- flags = profile .GetCommandFlags ("prune" )
832- assert .Equal (t , 2 , len (flags .ToMap ()))
833- assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
834- _ , found = flags .ToMap ()["other-flag-prune" ]
835- assert .True (t , found )
836-
837- flags = profile .GetCommandFlags ("mount" )
838- assert .Equal (t , 2 , len (flags .ToMap ()))
839- assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
840- _ , found = flags .ToMap ()["other-flag-mount" ]
841- assert .True (t , found )
842-
843- flags = profile .GetCommandFlags ("copy" )
844- assert .Equal (t , 2 , len (flags .ToMap ()))
845- assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
846- _ , found = flags .ToMap ()["other-flag-copy" ]
847- assert .True (t , found )
872+ commands := []string {
873+ "backup" ,
874+ "check" ,
875+ "copy" ,
876+ "dump" ,
877+ "find" ,
878+ "forget" ,
879+ "ls" ,
880+ "prune" ,
881+ "mount" ,
882+ "restore" ,
883+ "snapshots" ,
884+ "stats" ,
885+ "tag" ,
886+ }
887+
888+ for _ , command := range commands {
889+ t .Run (command , func (t * testing.T ) {
890+ flags = profile .GetCommandFlags (command )
891+ commandFlagName := "other-flag-" + command
892+ assert .Equal (t , 2 , len (flags .ToMap ()))
893+ assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
894+ _ , found = flags .ToMap ()[commandFlagName ]
895+ assert .True (t , found , commandFlagName )
896+ })
897+ }
848898 })
849899 }
850900}
0 commit comments