<commit_before>(ns taoensso.faraday.tests.main
  (:require [expectations           :as test :refer :all]
            [taoensso.faraday       :as far]
            [taoensso.faraday.utils :as utils]
            [taoensso.nippy         :as nippy]))

;; TODO LOTS of tests still outstanding, PRs very, very welcome!!

;;;; Config & setup

(defonce creds {:access-key (get (System/getenv) "AWS_DYNAMODB_ACCESS_KEY")
                :secret-key (get (System/getenv) "AWS_DYNAMODB_SECRET_KEY")})

(def ttable :faraday.tests.main)

(defn- before-run {:expectations-options :before-run} []
  (println "Setting up testing environment...")
  (far/ensure-table creds ttable {:name :id :type :n}
    {:throughput  {:read 1 :write 1}
     :block?      true})
  (println "Ready to roll..."))

(defn- after-run {:expectations-options :after-run} [])

(comment (far/delete-table creds ttable))

;;;; Basic API

(let [i0 {:id 0 :name "foo"}
      i1 {:id 1 :name "bar"}]

  (far/batch-write-item creds {ttable {:delete [{:id 0} {:id 1} {:id 2}]}})

  (expect ; Batch put
   [i0 i1 nil] (do (far/batch-write-item creds {ttable {:put [i0 i1]}})
                   [(far/get-item creds ttable {:id  0})
                    (far/get-item creds ttable {:id  1})
                    (far/get-item creds ttable {:id -1})]))
<commit_msg>Fix tests `before-run` (still had hash-keydef format)<commit_after>(ns taoensso.faraday.tests.main
  (:require [expectations           :as test :refer :all]
            [taoensso.faraday       :as far]
            [taoensso.faraday.utils :as utils]
            [taoensso.nippy         :as nippy]))

;; TODO LOTS of tests still outstanding, PRs very, very welcome!!

;;;; Config & setup

(defonce creds {:access-key (get (System/getenv) "AWS_DYNAMODB_ACCESS_KEY")
                :secret-key (get (System/getenv) "AWS_DYNAMODB_SECRET_KEY")})

(def ttable :faraday.tests.main)

(defn- before-run {:expectations-options :before-run} []
  (println "Setting up testing environment...")
  (far/ensure-table creds ttable [:id :n]
    {:throughput  {:read 1 :write 1}
     :block?      true})
  (println "Ready to roll..."))

(defn- after-run {:expectations-options :after-run} [])

(comment (far/delete-table creds ttable))

;;;; Basic API

(let [i0 {:id 0 :name "foo"}
      i1 {:id 1 :name "bar"}]

  (far/batch-write-item creds {ttable {:delete [{:id 0} {:id 1} {:id 2}]}})

  (expect ; Batch put
   [i0 i1 nil] (do (far/batch-write-item creds {ttable {:put [i0 i1]}})
                   [(far/get-item creds ttable {:id  0})
                    (far/get-item creds ttable {:id  1})
                    (far/get-item creds ttable {:id -1})]))

{'fraction_non_alphanumeric': 0.16226415094339622, 'fraction_numerical': 0.012075471698113207, 'mean_word_length': 2.616643929058663, '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': '1993146', 'n_tokens_mistral': 1015, 'n_tokens_neox': 937, 'n_words': 260}