示例#1
0
文件: db_test.go 项目: vozhyk-/gohan
			Expect(db.CopyDBResources(inDB, outDB, true)).To(Succeed())

			Expect(db.CopyDBResources(outDB, verifyDB, true)).To(Succeed())

			inTx, err := inDB.Begin()
			Expect(err).ToNot(HaveOccurred())
			defer inTx.Close()

			// SQL returns different types than JSON/YAML Database
			// So we need to move it back again so that DeepEqual would work correctly
			verifyTx, err := verifyDB.Begin()
			Expect(err).ToNot(HaveOccurred())
			defer verifyTx.Close()

			for _, s := range manager.OrderedSchemas() {
				if s.Metadata["type"] == "metaschema" {
					continue
				}
				resources, _, err := inTx.List(s, nil, nil)
				Expect(err).ToNot(HaveOccurred())
				for _, inResource := range resources {
					outResource, err := verifyTx.Fetch(s, transaction.Filter{"id": inResource.ID()})
					Expect(err).ToNot(HaveOccurred())
					Expect(outResource).To(Equal(inResource))
				}
			}
		})

		It("Should not override existing rows", func() {
			inDB, err := db.ConnectDB("yaml", "test_data/conv_in.yaml", db.DefaultMaxOpenConn)