Back
set-test (clj)
(source)macro
(set-test name & body)
Experimental.
Sets :test metadata of the named var to a fn with the given body.
The var must already exist. Does not modify the value of the var.
When *load-tests* is false, set-test is ignored.
Examples
xtdb/xtdb
(ns xtdb.jdbc-startup-test
(:require [clojure.java.io :as io]
[clojure.test :as t]
[juxt.clojars-mirrors.nextjdbc.v1v2v674.next.jdbc :as jdbc]
[xtdb.api :as xt]
[xtdb.fixtures :as fix]
[xtdb.fixtures.jdbc :as fj])
(:import (clojure.lang ExceptionInfo)
(java.util.concurrent ExecutionException Executors TimeUnit)
(java.util.concurrent.locks ReadWriteLock ReentrantReadWriteLock)))
(require 'clojure.java.shell)
(clojure.java.shell/sh "docker-compose" "up" "-d" :dir "modules/jdbc")
(clojure.java.shell/sh "docker-compose" "down" :dir "modules/jdbc")
(fj/set-test-dialects! :mysql :mssql :postgres :h2 :sqlite)
metosin/reitit
(ns reitit.trie-test
(:require [clojure.test :refer [are deftest is testing]]
[reitit.trie :as trie]))
(deftest into-set-test
(is (= #{} (trie/into-set nil)))
(is (= #{} (trie/into-set [])))
(is (= #{1} (trie/into-set 1)))
(is (= #{1 2} (trie/into-set [1 2 1]))))
HumbleUI/HumbleUI
(ns io.github.humbleui.event-test
(:require
[clojure.test :as test :refer [deftest is are testing]]
[io.github.humbleui.event :as event]))
(deftest mask->set-test
(testing "when mask is zero or empty keys"
(are [mask keys res] (= (mask->set mask keys) res)
0 [] #{}
0 [:a :b :c] #{}
42 [] #{}))
juxt/bidi
(ns bidi.bidi-test
(:require
#?(:clj [clojure.test :refer :all]
:cljs [cljs.test :refer-macros [deftest is testing]])
[bidi.bidi :as bidi :refer [match-route path-for ->Alternates route-seq alts tag]]))
(deftest wrap-set-test
(let [routes [#{"/index.html" "/index"} :index]]
(is (= (match-route routes "/index.html") {:handler :index}))
(is (= (match-route routes "/index") {:handler :index}))
(is (= (path-for routes :index) "/index.html"))) ; first is the canonical one
(let [routes [#{"/index.html" "/index"} :index]]
(is (= (match-route routes "/index.html") {:handler :index}))
(is (= (match-route routes "/index") {:handler :index}))))
(deftest similar-set-test
(let [routes-test ["/" {#{"index" "index-x" "index.html" "x-index.html" "index-x.html" "x.html"} :index}]]
(= (match-route routes-test "/index") :index)
(= (match-route routes-test "/index-x") :index)
(= (match-route routes-test "/index.html") :index)
(= (match-route routes-test "/x.html") :index)
(= (match-route routes-test "/x-index.html") :index)
(= (match-route routes-test "/index-x.html") :index)))
pallet/pallet
(ns pallet.actions.direct.exec-script-test
(:require
[clojure.test :refer :all]
[pallet.actions :refer [exec exec-checked-script exec-script exec-script*]]
[pallet.algo.fsmop :refer [failed?]]
[pallet.api :refer [group-spec lift plan-fn server-spec]]
[pallet.build-actions :refer [build-actions let-actions]]
[pallet.common.logging.logutils :refer [logging-threshold-fixture
with-log-to-string]]
[pallet.compute :as compute]
[pallet.compute.node-list :as node-list]
[pallet.core.primitives :refer [phase-errors throw-phase-errors]]
[pallet.core.user :refer [*admin-user*]]
[pallet.node :refer [hostname]]
[pallet.node-value :refer [node-value]]
[pallet.script-builder :refer [interpreter]]
[pallet.script.lib :refer [ls]]
[pallet.stevedore :as stevedore]
[pallet.stevedore :refer [with-source-line-comments]]
[pallet.test-utils
:refer [no-location-info
no-source-line-comments
script-action
test-username
with-bash-script-language
with-location-info]]))
(deftest lift-all-node-set-test
(let [local (group-spec
"local"
:phases {:configure (plan-fn (print-action "hello"))})
localhost (node-list/make-localhost-node :group-name "local")
service (compute/instantiate-provider
"node-list" :node-list [localhost])]
(testing "python"
(let [session (lift
local
:user (assoc *admin-user*
:username (test-username) :no-sudo true)
:compute service)]
(is (= ["hello\n"]
(->>
session
:results
(filter
#(and (= "localhost" (hostname (-> % :target :node)))
(= :configure (:phase %))))
(mapcat :result)
(map :out))))))))