Пример #1
0
		} 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()

		Ω(coast.Store()).Should(BeNil())
Пример #2
0
		} else {
			err = os.Unsetenv("HOME")
			Ω(err).Should(BeNil())
		}

		// Clear the Cache
		config.ClearPathCache()
	})

	It("should log to a file", func() {
		err := InitializeLoggers(LevelInfo)
		Ω(err).Should(BeNil())
		defer CloseLoggers()

		Log("test log message", LevelInfo)
		Ω(config.PathExists(logPath)).Should(BeTrue())

		data, err := ioutil.ReadFile(logPath)
		Ω(err).Should(BeNil())

		logPattern := `INFO    \[\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[-+]\d{2}:\d{2}\]: test log message\n`
		Ω(string(data)).Should(MatchRegexp(logPattern))
	})

	It("should not log if the level is less than minimum level", func() {
		err := InitializeLoggers(LevelWarn)
		Ω(err).Should(BeNil())
		defer CloseLoggers()

		Log("test log message", LevelInfo)
		Log("test warning message", LevelWarn)