<commit_before>(ns yetibot.core.test.config-mutable
  (:require
    [clojure.java.io :refer [delete-file]]
    [yetibot.core.config-mutable :refer :all]
    [schema.core :as s]
    [clojure.test :refer :all]))

(def test-config-path "config/test-config-mutable.edn")

(defn wrap [f]
  ;; ensure config exists
  (reload-config! test-config-path)
  (let [original-config @@#'yetibot.core.config/config]
    ;; run all the tests
    (f)
    ;; delete config file
    (delete-file test-config-path)))

(use-fixtures :once wrap)

(deftest test-config-is-loaded
  (is (not (nil? (get-config {} [:yetibot])))))

(deftest test-update-config
  (is (config-exists? test-config-path))
  (update-config! test-config-path [:yetibot :foo :bar] "baz")
  (is (= "baz" (:value (get-config String [:yetibot :foo :bar]))))
  ;; re-read from disk
  (reload-config! test-config-path)
  (is (= "baz" (:value (get-config String [:yetibot :foo :bar])))))

(deftest test-apply-config
  ;; create a new value
  (apply-config! test-config-path [:yetibot :apply-test] (constantly "apply"))
  (is (= "apply" (:value (get-config String [:yetibot :apply-test]))) "apply")
  ;; modify the existing value
  (apply-config! test-config-path
    [:yetibot :apply-test]
    #(.toUpperCase %))
  (is (= "APPLY" (:value (get-config String [:yetibot :apply-test])))))
<commit_msg>Use a mutable test file in root dir<commit_after>(ns yetibot.core.test.config-mutable
  (:require
    [clojure.java.io :refer [delete-file]]
    [yetibot.core.config-mutable :refer :all]
    [schema.core :as s]
    [clojure.test :refer :all]))

(def test-config-path "test-config-mutable.edn")

(defn wrap [f]
  ;; ensure config exists
  (reload-config! test-config-path)
  (let [original-config @@#'yetibot.core.config/config]
    ;; run all the tests
    (f)
    ;; delete config file
    (delete-file test-config-path)))

(use-fixtures :once wrap)

(deftest test-config-is-loaded
  (is (not (nil? (get-config {} [:yetibot])))))

(deftest test-update-config
  (is (config-exists? test-config-path))
  (update-config! test-config-path [:yetibot :foo :bar] "baz")
  (is (= "baz" (:value (get-config String [:yetibot :foo :bar]))))
  ;; re-read from disk
  (reload-config! test-config-path)
  (is (= "baz" (:value (get-config String [:yetibot :foo :bar])))))

(deftest test-apply-config
  ;; create a new value
  (apply-config! test-config-path [:yetibot :apply-test] (constantly "apply"))
  (is (= "apply" (:value (get-config String [:yetibot :apply-test]))) "apply")
  ;; modify the existing value
  (apply-config! test-config-path
    [:yetibot :apply-test]
    #(.toUpperCase %))
  (is (= "APPLY" (:value (get-config String [:yetibot :apply-test])))))

{'fraction_non_alphanumeric': 0.18664192949907235, 'fraction_numerical': 0.0, 'mean_word_length': 3.9107468123861566, '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': '4030372', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1002, 'n_words': 241}