// Initialize the database in the config location func InitializeDatabase() error { var err error var path string if path, err = config.CrateDatabasePath(); err == nil { if db, err = leveldb.OpenFile(path, nil); err != nil { return err } } else { return err } return nil }
err = os.Unsetenv("USERPROFILE") Ω(err).Should(BeNil()) } else { err = os.Unsetenv("HOME") Ω(err).Should(BeNil()) } // Clear the Cache config.ClearPathCache() }) It("should initialize the database in the data directory", func() { Ω(InitializeDatabase()).Should(BeNil()) defer CloseDatabase() dbpath, err := config.CrateDatabasePath() Ω(err).Should(BeNil()) Ω(config.PathExists(dbpath)).Should(BeTrue()) }) It("should be able to store a filemeta in the database", func() { Ω(InitializeDatabase()).Should(BeNil()) defer CloseDatabase() Ω(dracula.Store()).Should(BeNil()) Ω(FetchKeys(2)).Should(ContainElement(dracula.Signature)) }) It("should be able to store an imagemeta in the database", func() { Ω(InitializeDatabase()).Should(BeNil()) defer CloseDatabase()