So I tried some more and figured out that its the ::autoinc key that causes this: (s/def ::column (s/keys :req-un [::name ::type] :opt-un [::null ::max-length ::required ::pk ::autoinc ;;;;;;;; this one ::unique ::default ::refs ::fk-name]))
When I comment that key, no error occurs, if I uncomment it, spec validation errors repeatedly. The only connection I see is that I remove exactly this k/v pair from the map in my specced function: (s/fdef remove-autoinc-columns :args (s/cat :cols (s/spec ::schem/columns)) :ret ::schem/columns) (defn remove-autoinc-columns [cols] (remove #(= true (:autoinc %)) cols)) But still, as it is an optional key I dont see why it should cause errors? Thanks, Sven Am Montag, 30. Mai 2016 07:38:19 UTC+2 schrieb Sven Richter: > > Hi, > > So I looked at generating specs for tests and I hit an error I just dont > understand / neither can fix it. This is my code: > > (s/def ::column-types #{:int :varchar :boolean :text :time :date > :char :binary :smallint :bigint :decimal > :float :double :real :timestamp}) > > (s/def ::name (s/and string? #(not= "" %))) > (s/def ::boolean (s/or :t true? :f false?)) > > (s/def ::type ::column-types) > (s/def ::null ::boolean) > (s/def ::max-length (s/and integer? #(< 0 %))) > (s/def ::required ::boolean) > (s/def ::pk ::boolean) > (s/def ::autoinc ::boolean) > (s/def ::unique ::boolean) > (s/def ::default (s/or :string string? :boolean ::boolean)) > (s/def ::refs ::none-empty-string) > (s/def ::fk-name ::none-empty-string) > > (s/def ::column (s/keys :req-un [::name ::type] > :opt-un [::null ::max-length ::required ::pk > ::autoinc ::unique ::default > ::refs ::fk-name])) > (s/def ::columns (s/cat :column (s/+ ::column))) > > ;function > (s/fdef remove-autoinc-columns :args (s/cat :cols (s/spec columns)) > :ret ::schem/columns) > (defn remove-autoinc-columns [cols] > (vec (remove #(= true (:autoinc %)) cols))) > > > > ; generative test > (defspec remove-autoinc-column 100 > (prop/for-all [columns (s/gen ::schem/columns)] > (= (h/remove-autoinc-columns columns)))) > > ; will fail with something along the lines of: > ERROR in (remove-autoinc-column) (core.clj:4617) > Uncaught exception, not in assertion. > expected: nil > actual: clojure.lang.ExceptionInfo: Call to > #'de.sveri.clospcrud.helper/remove-autoinc-columns did not conform to spec: > val: () fails spec: :de.sveri.clospcrud.spec.clospcrud/columns at: [:ret > :column] predicate: :de.sveri.clospcrud.spec.clospcrud/column, > Insufficient input > :clojure.spec/args (({:name "QpJ50qrS1m24V", :type :varchar, :unique > true, :required false, :autoinc true, :null true, :pk true, :max-length 14, > :fk-name "Tp9tG8hwUXK0"})) > > I cannot see where the error is coming from, I generate data according to > a spec which I pass to a function that takes this spec exactly. > > Any ideas? > > Thanks, > Sven > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.