diff --git a/integration/wrappers_test.go b/integration/wrappers_test.go index 858d5210d..5e41ac66e 100644 --- a/integration/wrappers_test.go +++ b/integration/wrappers_test.go @@ -18,12 +18,12 @@ var _ = Describe("Wrappers Integration", func() { Describe("RetrieveAndProcessTables", func() { BeforeEach(func() { rootCmd := &cobra.Command{} + includes := []string{"--include-table", "public.foo", "--include-table", "public.BAR"} + rootCmd.SetArgs(options.HandleSingleDashes(includes)) backup.DoInit(rootCmd) // initialize the ObjectCount + rootCmd.Execute() }) It("returns the data tables that have names with special characters", func() { - _ = backupCmdFlags.Set(options.INCLUDE_RELATION, "public.foo") - _ = backupCmdFlags.Set(options.INCLUDE_RELATION, "public.BAR") - testhelper.AssertQueryRuns(connectionPool, "CREATE TABLE public.foo(i int); INSERT INTO public.foo VALUES (1);") testhelper.AssertQueryRuns(connectionPool, `CREATE TABLE public."BAR"(i int); INSERT INTO public."BAR" VALUES (1);`) defer testhelper.AssertQueryRuns(connectionPool, "DROP TABLE public.foo;") @@ -63,10 +63,6 @@ var _ = Describe("Wrappers Integration", func() { rootCmd := &cobra.Command{} backup.DoInit(rootCmd) // initialize the ObjectCount - subject, err := options.NewOptions(backupCmdFlags) - Expect(err).To(Not(HaveOccurred())) - backup.ValidateAndProcessFilterLists(subject) - _, dataTables, _ := backup.RetrieveAndProcessTables() Expect(len(dataTables)).To(Equal(3)) Expect(dataTables[0].Name).To(Equal("thousands")) @@ -80,13 +76,6 @@ var _ = Describe("Wrappers Integration", func() { backup.DoInit(rootCmd) // initialize the ObjectCount rootCmd.Execute() - _ = backupCmdFlags.Set(options.INCLUDE_RELATION, "public.empty") - _ = backupCmdFlags.Set(options.INCLUDE_RELATION, "public.ten") - - subject, err := options.NewOptions(backupCmdFlags) - Expect(err).To(Not(HaveOccurred())) - backup.ValidateAndProcessFilterLists(subject) - _, dataTables, _ := backup.RetrieveAndProcessTables() Expect(len(dataTables)).To(Equal(2)) Expect(dataTables[0].Name).To(Equal("ten")) @@ -99,12 +88,6 @@ var _ = Describe("Wrappers Integration", func() { backup.DoInit(rootCmd) // initialize the ObjectCount rootCmd.Execute() - _ = backupCmdFlags.Set(options.EXCLUDE_RELATION, "public.thousands") - - subject, err := options.NewOptions(backupCmdFlags) - Expect(err).To(Not(HaveOccurred())) - backup.ValidateAndProcessFilterLists(subject) - _, dataTables, _ := backup.RetrieveAndProcessTables() Expect(len(dataTables)).To(Equal(2)) Expect(dataTables[0].Name).To(Equal("ten")) @@ -136,12 +119,6 @@ var _ = Describe("Wrappers Integration", func() { backup.DoInit(rootCmd) // initialize the ObjectCount rootCmd.Execute() - _ = backupCmdFlags.Set(options.INCLUDE_SCHEMA, "filterschema") - - subject, err := options.NewOptions(backupCmdFlags) - Expect(err).To(Not(HaveOccurred())) - backup.ValidateAndProcessFilterLists(subject) - _, dataTables, _ := backup.RetrieveAndProcessTables() Expect(len(dataTables)).To(Equal(2)) Expect(dataTables[0].Name).To(Equal("thousands")) @@ -154,12 +131,6 @@ var _ = Describe("Wrappers Integration", func() { backup.DoInit(rootCmd) // initialize the ObjectCount rootCmd.Execute() - _ = backupCmdFlags.Set(options.EXCLUDE_SCHEMA, "public") - - subject, err := options.NewOptions(backupCmdFlags) - Expect(err).To(Not(HaveOccurred())) - backup.ValidateAndProcessFilterLists(subject) - _, dataTables, _ := backup.RetrieveAndProcessTables() Expect(len(dataTables)).To(Equal(2)) Expect(dataTables[0].Name).To(Equal("thousands")) @@ -193,12 +164,8 @@ var _ = Describe("Wrappers Integration", func() { rootCmd := &cobra.Command{} backup.DoInit(rootCmd) // initialize the ObjectCount - subject, err := options.NewOptions(backupCmdFlags) - Expect(err).To(Not(HaveOccurred())) - backup.ValidateAndProcessFilterLists(subject) - - includeOids := backup.GetOidsFromRelationList(backup.IncludedRelationFqns) - err = backup.ExpandIncludesForPartitions(connectionPool, subject, includeOids, backupCmdFlags) + opts, _ := options.NewOptions(rootCmd.Flags()) + err := opts.ExpandIncludesForPartitions(connectionPool, rootCmd.Flags()) Expect(err).ShouldNot(HaveOccurred()) _, dataTables, _ := backup.RetrieveAndProcessTables() @@ -213,12 +180,8 @@ var _ = Describe("Wrappers Integration", func() { backup.DoInit(rootCmd) // initialize the ObjectCount rootCmd.Execute() - subject, err := options.NewOptions(backupCmdFlags) - Expect(err).To(Not(HaveOccurred())) - backup.ValidateAndProcessFilterLists(subject) - - includeOids := backup.GetOidsFromRelationList(backup.IncludedRelationFqns) - err = backup.ExpandIncludesForPartitions(connectionPool, subject, includeOids, backupCmdFlags) + opts, _ := options.NewOptions(rootCmd.Flags()) + err := opts.ExpandIncludesForPartitions(connectionPool, rootCmd.Flags()) Expect(err).ShouldNot(HaveOccurred()) _, dataTables, _ := backup.RetrieveAndProcessTables() @@ -252,10 +215,6 @@ var _ = Describe("Wrappers Integration", func() { rootCmd := &cobra.Command{} backup.DoInit(rootCmd) // initialize the ObjectCount - subject, err := options.NewOptions(backupCmdFlags) - Expect(err).To(Not(HaveOccurred())) - backup.ValidateAndProcessFilterLists(subject) - _, dataTables, _ := backup.RetrieveAndProcessTables() Expect(len(dataTables)).To(Equal(3)) @@ -275,10 +234,6 @@ var _ = Describe("Wrappers Integration", func() { rootCmd := &cobra.Command{} backup.DoInit(rootCmd) // initialize the ObjectCount - subject, err := options.NewOptions(backupCmdFlags) - Expect(err).To(Not(HaveOccurred())) - backup.ValidateAndProcessFilterLists(subject) - _, dataTables, _ := backup.RetrieveAndProcessTables() Expect(len(dataTables)).To(Equal(3))