github.com/tuhaihe/gpbackup@v1.0.3/integration/wrappers_test.go (about) 1 package integration 2 3 import ( 4 "github.com/tuhaihe/gp-common-go-libs/gplog" 5 "github.com/tuhaihe/gp-common-go-libs/testhelper" 6 "github.com/tuhaihe/gpbackup/backup" 7 "github.com/tuhaihe/gpbackup/options" 8 "github.com/spf13/cobra" 9 10 . "github.com/onsi/ginkgo/v2" 11 . "github.com/onsi/gomega" 12 ) 13 14 var _ = Describe("Wrappers Integration", func() { 15 Describe("RetrieveAndProcessTables", func() { 16 BeforeEach(func() { 17 gplog.SetVerbosity(gplog.LOGERROR) // turn off progress bar in the lock-table routine 18 var rootCmd = &cobra.Command{} 19 backup.DoInit(rootCmd) // initialize the ObjectCount 20 }) 21 It("returns the data tables that have names with special characters", func() { 22 _ = backupCmdFlags.Set(options.INCLUDE_RELATION, "public.foo") 23 _ = backupCmdFlags.Set(options.INCLUDE_RELATION, "public.BAR") 24 25 testhelper.AssertQueryRuns(connectionPool, "CREATE TABLE public.foo(i int); INSERT INTO public.foo VALUES (1);") 26 testhelper.AssertQueryRuns(connectionPool, `CREATE TABLE public."BAR"(i int); INSERT INTO public."BAR" VALUES (1);`) 27 defer testhelper.AssertQueryRuns(connectionPool, "DROP TABLE public.foo;") 28 defer testhelper.AssertQueryRuns(connectionPool, `DROP TABLE public."BAR";`) 29 30 // every backup occurs in a transaction; we are testing a small part of that backup 31 connectionPool.MustBegin(0) 32 defer connectionPool.MustCommit(0) 33 34 _, dataTables := backup.RetrieveAndProcessTables() 35 Expect(len(dataTables)).To(Equal(2)) 36 Expect(dataTables[0].Name).To(Equal("foo")) 37 Expect(dataTables[1].Name).To(Equal(`"BAR"`)) 38 }) 39 }) 40 })