@@ -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,10 @@ func TestHostInAllSupportedSections(t *testing.T) {
284287 constants .CommandSnapshots ,
285288 constants .CommandMount ,
286289 constants .SectionConfigurationRetention ,
290+ constants .CommandFind ,
291+ constants .CommandDump ,
292+ constants .CommandLs ,
293+ constants .CommandStats ,
287294 }
288295
289296 assertHostIs := func (expectedHost []string , profile * Profile , section string ) {
@@ -712,6 +719,18 @@ other-flag-prune = true
712719other-flag-mount = true
713720[profile.copy]
714721other-flag-copy = true
722+ [profile.dump]
723+ other-flag-dump = true
724+ [profile.find]
725+ other-flag-find = true
726+ [profile.ls]
727+ other-flag-ls = true
728+ [profile.restore]
729+ other-flag-restore = true
730+ [profile.stats]
731+ other-flag-stats = true
732+ [profile.tag]
733+ other-flag-tag = true
715734` },
716735 {"json" , `
717736{
@@ -724,7 +743,13 @@ other-flag-copy = true
724743 "forget": {"other-flag-forget": true},
725744 "prune": {"other-flag-prune": true},
726745 "mount": {"other-flag-mount": true},
727- "copy": {"other-flag-copy": true}
746+ "copy": {"other-flag-copy": true},
747+ "dump": {"other-flag-dump": true},
748+ "find": {"other-flag-find": true},
749+ "ls": {"other-flag-ls": true},
750+ "restore": {"other-flag-restore": true},
751+ "stats": {"other-flag-stats": true},
752+ "tag": {"other-flag-tag": true}
728753 }
729754}` },
730755 {"yaml" , `---
@@ -746,6 +771,18 @@ profile:
746771 other-flag-mount: true
747772 copy:
748773 other-flag-copy: true
774+ dump:
775+ other-flag-dump: true
776+ find:
777+ other-flag-find: true
778+ ls:
779+ other-flag-ls: true
780+ restore:
781+ other-flag-restore: true
782+ stats:
783+ other-flag-stats: true
784+ tag:
785+ other-flag-tag: true
749786` },
750787 {"hcl" , `
751788"profile" = {
@@ -774,6 +811,24 @@ profile:
774811 copy = {
775812 other-flag-copy = true
776813 }
814+ dump = {
815+ other-flag-dump = true
816+ }
817+ find = {
818+ other-flag-find = true
819+ }
820+ ls = {
821+ other-flag-ls = true
822+ }
823+ restore = {
824+ other-flag-restore = true
825+ }
826+ stats = {
827+ other-flag-stats = true
828+ }
829+ tag = {
830+ other-flag-tag = true
831+ }
777832}
778833` },
779834 }
@@ -794,57 +849,49 @@ profile:
794849 require .NotNil (t , profile .Prune )
795850 require .NotNil (t , profile .Snapshots )
796851 require .NotNil (t , profile .Copy )
852+ require .NotNil (t , profile .Dump )
853+ require .NotNil (t , profile .Find )
854+ require .NotNil (t , profile .Ls )
855+ require .NotNil (t , profile .Restore )
856+ require .NotNil (t , profile .Stats )
857+ require .NotNil (t , profile .Tag )
797858
798859 flags := profile .GetCommonFlags ()
799860 assert .Equal (t , 1 , len (flags .ToMap ()))
800861 assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
801862
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-
807863 flags = profile .GetRetentionFlags ()
808864 assert .Equal (t , 2 , len (flags .ToMap ()))
809865 assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
810866 _ , found := flags .ToMap ()["other-flag-retention" ]
811867 assert .True (t , found )
812868
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 )
869+ commands := []string {
870+ "backup" ,
871+ "check" ,
872+ "copy" ,
873+ "dump" ,
874+ "find" ,
875+ "forget" ,
876+ "ls" ,
877+ "prune" ,
878+ "mount" ,
879+ "restore" ,
880+ "snapshots" ,
881+ "stats" ,
882+ "tag" ,
883+ }
884+
885+ for _ , command := range commands {
886+ t .Run (command , func (t * testing.T ) {
887+ flags = profile .GetCommandFlags (command )
888+ commandFlagName := "other-flag-" + command
889+ assert .Equal (t , 2 , len (flags .ToMap ()))
890+ assert .ElementsMatch (t , []string {"1" }, flags .ToMap ()["other-flag" ])
891+ _ , found = flags .ToMap ()[commandFlagName ]
892+ assert .True (t , found , commandFlagName )
893+ })
894+ }
848895 })
849896 }
850897}
0 commit comments