From 09c0a46881139153542fbe3273a653d1c2303ad1 Mon Sep 17 00:00:00 2001 From: Jeff Rose Date: Thu, 2 Jul 2015 15:09:35 -0600 Subject: [PATCH] Add unit test for 3rd-party rotor appender (@rosejn) --- .../timbre/appenders/3rd_party/rotor.clj | 2 -- .../timbre/appenders/3rd_party/rotor_test.clj | 29 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 test/taoensso/timbre/appenders/3rd_party/rotor_test.clj diff --git a/src/taoensso/timbre/appenders/3rd_party/rotor.clj b/src/taoensso/timbre/appenders/3rd_party/rotor.clj index 51654c6..284d70a 100644 --- a/src/taoensso/timbre/appenders/3rd_party/rotor.clj +++ b/src/taoensso/timbre/appenders/3rd_party/rotor.clj @@ -4,8 +4,6 @@ [taoensso.timbre :as timbre]) (:import [java.io File FilenameFilter])) -;; TODO Test port to Timbre v4 - (defn- ^FilenameFilter file-filter "Returns a Java FilenameFilter instance which only matches files with the given `basename`." diff --git a/test/taoensso/timbre/appenders/3rd_party/rotor_test.clj b/test/taoensso/timbre/appenders/3rd_party/rotor_test.clj new file mode 100644 index 0000000..beb1ab0 --- /dev/null +++ b/test/taoensso/timbre/appenders/3rd_party/rotor_test.clj @@ -0,0 +1,29 @@ +(ns taoensso.timbre.appenders.3rd-party.rotor-test + (:require + [clojure.test :refer :all] + [clojure.java.io :as io] + [taoensso.timbre :as timbre] + [taoensso.timbre.appenders.3rd-party.rotor :as rotor])) + +(deftest rotor-test + [] + (let [logfile "rotor-test.log" + n-logs 5] + (timbre/merge-config! + {:appenders {:rotor (rotor/rotor-appender + {:path logfile + :max-size 200 + :backlog n-logs})}}) + (doseq [i (range 100)] + (timbre/info "testing...")) + + (let [f (io/file logfile)] + (is (.exists f)) + (.delete f)) + + (doseq [i (range 1 (inc n-logs))] + (let [f (io/file (str logfile ".00" i))] + (is (.exists f)) + (.delete f))))) + +