<commit_before>(ns riemann.xymon-test
  (:use riemann.xymon
        [riemann.time :only [unix-time]]
        clojure.test)
  (:require [riemann.logging :as logging]))

(logging/init)

(deftest ^:xymon ^:integration xymon-test
         (let [k (xymon nil)]
           (k {:host "riemann.local"
               :service "xymon test"
               :state "green"
               :description "all clear, uh, situation normal"
               :metric -2
               :time (unix-time)}))

         (let [k (xymon nil)]
           (k {:service "xymon test"
               :state "green"
               :description "all clear, uh, situation normal"
               :metric 3.14159
               :time (unix-time)}))

         (let [k (xymon nil)]
           (k {:host "riemann.local"
	       :service "xymon test"
               :state "ok"
               :description "all clear, uh, situation normal"
               :metric 3.14159
               :time (unix-time)}))
<commit_msg>add a way to test for format-line's output<commit_after>(ns riemann.xymon-test
  (:use riemann.xymon
        [riemann.time :only [unix-time]]
        clojure.test)
  (:require [riemann.logging :as logging]))

(logging/init)

(deftest ^:xymon-format format-line-test
  (let [pairs [[{}
                "status . unknown \n"]
               [{:host "foo" :service "bar"}
                "status foo.bar unknown \n"]
               [{:host "foo" :service "bar" :state "ok"}
                "status foo.bar ok \n"]
               [{:host "foo" :service "bar" :state "ok" :description "blah"}
                "status foo.bar ok blah\n"]
               [{:host "foo" :service "bar" :state "ok" :ttl 300}
                "status+300 foo.bar ok \n"]
               [{:host "example.com" :service "some.metric rate" :state "ok"}
                "status example,com.some_metric_rate ok \n"]]]
    (doseq [[event line] pairs]
      (is (= line (format-line event))))))

(deftest ^:xymon ^:integration xymon-test
         (let [k (xymon nil)]
           (k {:host "riemann.local"
               :service "xymon test"
               :state "green"
               :description "all clear, uh, situation normal"
               :metric -2
               :time (unix-time)}))

         (let [k (xymon nil)]
           (k {:service "xymon test"
               :state "green"
               :description "all clear, uh, situation normal"
               :metric 3.14159
               :time (unix-time)}))

         (let [k (xymon nil)]
           (k {:host "riemann.local"
	       :service "xymon test"
               :state "ok"
               :description "all clear, uh, situation normal"
               :metric 3.14159
               :time (unix-time)}))

{'fraction_non_alphanumeric': 0.1380198748619801, 'fraction_numerical': 0.011777695988222304, 'mean_word_length': 1.5811965811965811, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4894161', 'n_tokens_mistral': 898, 'n_tokens_neox': 812, 'n_words': 238}