- Tests for the core.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(seed-table | |
{:database {:vendor :mysql :db "simulation" :user "root" :password ""} :table :persons :policy :clean-slate :n 50} | |
(seed | |
(randomized :name) | |
(randomized :number) | |
(randomized :age {:min 0 :max 90}) | |
(randomized :nickname {:length 15}))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def db {:vendor :mysql :db "simulation" :user "root" :password ""}) | |
(defseed pet-rooms | |
{:database db :table :rooms} | |
(inherit :name)) | |
(defseed pets | |
{:database db :table :pets} | |
(inherit :pid) | |
(randomized :name {:fk [pet-rooms :name]})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> describe persons; | |
+--------+---------------+------+-----+---------+-------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+--------+---------------+------+-----+---------+-------+ | |
| name | varchar(32) | YES | | NULL | | | |
| number | int(11) | YES | | NULL | | | |
| money | decimal(10,2) | YES | | NULL | | | |
| about | varchar(50) | YES | | NULL | | | |
| secret | float(10,2) | YES | | NULL | | | |
+--------+---------------+------+-----+---------+-------+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(seed-table | |
{:database {:db "stuff" :username "xx" :password "xx" :vendor :mongo} :policy :clean-slate :n 50 | |
:types {:name {:type :string :min 5 :max 10} | |
:age {:type :integer :min 0 :max 99} | |
:zip {:type :string :exactly 5}} | |
(randomized :name) | |
(randomized :age) | |
(randomized :zip)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(request! | |
{:url "http://localhost:3000/api/v1/sensor/:id"} | |
(url-params> (randomized-integer :id)) | |
(query-string> (randomized-string :name) | |
(value-of :auth_token "ABCDEF0123456789"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns rjm-seeding.core | |
(:require [dibble.core :refer [defseed]])) | |
(defseed users | |
{:database {:db "rjmadmin" :user "root" :password "" :vendor :mysql} :table :rjm_users} | |
[:inherit :uid] | |
[:randomized :salt :length 5] | |
[:randomized :saltedpw :length 5] | |
[:randomized :email :length 5] | |
[:value-of :browser (rand-nth ["firefox" "chrome" "ie"])] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(request | |
[:post :to "http://localhost:3000/books"] | |
[:edn {:title "A Tale of Two Cities" :year 1859}]) | |
(request | |
[:post :to "http://localhost:3000/books"] | |
{:headers {:X-Api-Version "2"} | |
:socket-timeout 1000 | |
:conn-timeout 1000 | |
:body [:json {:title "A Tale of Two Cities" :year 1859}]}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Form 1 | |
(defprecondition some-func | |
(fn [& args] | |
(assert-conditions args)) | |
(fn [e & args] | |
(error-handling args))) | |
;;; Form 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defprotocol Fly | |
(fly [this] "Method to fly")) | |
(defn bird-fly [this] | |
(str (:name this) " flies...")) | |
(with-precondition! #'bird-fly | |
:not-crow | |
(fn [this] (not= (:name this) "Crow"))) |