babashka/test-resources/lib_tests/expound/problems_test.cljc
Gabriel Horner 665ae4dd97
Finish up library tests (#1120)
* Add tests for markdown-clj and tools.namespace

See comment for why only one markdown test could be run.
Closes #1069 and #1064

* Convert 10 test libs using add-libtest

Also improved add-libtest to only require maven artifact
and rely on clojars for getting git-url most of the time

* Convert 8 more test libs using add-libtest

Also updated table and added comment for newline test

* Fix doric test

* Disable tools.namespace test that fails on windows

* Added dozen manual test libs and converted 2 test libs

add-libtest.clj supports manually-added and test-directories options

* Converts last tests to test namespaces and write libraries.csv

* Add a number of library tests from projects.md

Also add more docs around adding test libs and tweak add script

* Use :sha for gitlib and older clojure cli

* Revert "Use :sha for gitlib and older clojure cli"

This reverts commit c663ab8368.

* Fix and disable failing tests

Disabled tests that fail consistently and fixed windows one
2021-12-29 16:35:14 +01:00

30 lines
No EOL
1.1 KiB
Clojure

(ns expound.problems-test
(:require [clojure.test :as ct :refer [is deftest use-fixtures]]
[clojure.spec.alpha :as s]
[expound.problems :as problems]
[expound.test-utils :as test-utils]))
(use-fixtures :once
test-utils/check-spec-assertions
test-utils/instrument-all)
(s/def :highlighted-value/nested-map-of (s/map-of keyword? (s/map-of keyword? keyword?)))
(s/def :highlighted-value/city string?)
(s/def :highlighted-value/address (s/keys :req-un [:highlighted-value/city]))
(s/def :highlighted-value/house (s/keys :req-un [:highlighted-value/address]))
(s/def :annotate-test/div-fn (s/fspec
:args (s/cat :x int? :y pos-int?)))
(defn my-div [x y]
(assert (pos? (/ x y))))
(deftest annotate-test
(is (= {:expound/in [0]
:val '(0 1)
:reason "Assert failed: (pos? (/ x y))"}
(-> (s/explain-data (s/coll-of :annotate-test/div-fn) [my-div])
problems/annotate
:expound/problems
first
(select-keys [:expound/in :val :reason])))))