Fork me on GitHub
#polylith
<
2024-07-10
>
Nikolas Pafitis19:07:07

I have yet more issues with poly test 0.2.19. I have this code:

(ns streamcraft.persistence-schema-transformer-malli-datomic.core-test
  (:require [clojure.test :refer [deftest is testing use-fixtures]]
            ...)

...

(deftest transform--test
  (is (= 1 2))
  (testing "Transforming a simple schema to Datomic schema"
    (is (= 1 2))
    (let [{:keys [transformer]} *system*]
      (is (= [{:db/ident       :simple-person/name
               :db/valueType   :db.type/string
               :db/cardinality :db.cardinality/one
               :db/fulltext    true}
              {:db/ident       :simple-person/age
               :db/valueType   :db.type/long
               :db/cardinality :db.cardinality/one}
              {:db/ident       :simple-person/email
               :db/valueType   :db.type/string
               :db/cardinality :db.cardinality/one
               :db/fulltext    true}
              {:db/ident       :simple-person/active
               :db/valueType   :db.type/boolean
               :db/cardinality :db.cardinality/one}]
             (ts/transform transformer :simple-person))))))
When i run the test runners (this happens on any test runner, default, kaocha and @seancorfield 's) I get the following output (on default test runner)
Test results: 0 passes, 0 failures, 0 errors.

Testing streamcraft.persistence-schema-transformer-malli-datomic.core-test
2024-07-10T19:51:38.436Z Nikolass-MBP INFO [streamcraft.entity.core:17] - Starting MalliEntityRegistry
2024-07-10T19:51:38.437Z Nikolass-MBP INFO [streamcraft.persistence-schema-transformer-malli-datomic.core:47] - Starting EntityPersistenceSchemaTransformer
2024-07-10T19:51:38.437Z Nikolass-MBP INFO [streamcraft.persistence-schema-transformer-malli-datomic.core:51] - Stopping EntityPersistenceSchemaTransformer
2024-07-10T19:51:38.437Z Nikolass-MBP INFO [streamcraft.entity.core:22] - Stopping MalliEntityRegistry

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
and in kaocha:
FAIL in streamcraft.persistence-schema-transformer-malli-datomic.core-test/transform--test (streamcraft/persistence_schema_transformer_malli_datomic/core_test.cljc:23)
Test ran without assertions. Did you forget an (is ...)?
╭───── Test output ───────────────────────────────────────────────────────
│ 2024-07-10T19:54:14.972Z Nikolass-MBP INFO [streamcraft.entity.core:17] - Starting MalliEntityRegistry
│ 2024-07-10T19:54:14.972Z Nikolass-MBP INFO [streamcraft.persistence-schema-transformer-malli-datomic.core:47] - Starting EntityPersistenceSchemaTransformer
│ 2024-07-10T19:54:14.973Z Nikolass-MBP INFO [streamcraft.persistence-schema-transformer-malli-datomic.core:51] - Stopping EntityPersistenceSchemaTransformer
│ 2024-07-10T19:54:14.973Z Nikolass-MBP INFO [streamcraft.entity.core:22] - Stopping MalliEntityRegistry
╰─────────────────────────────────────────────────────────────────────────
Relevant aliases for tests:
:test      {:extra-paths ["components/utils/test"]
                         :extra-deps  {polylith-kaocha/kaocha-wrapper
                                       {:git/url   ""
                                        :git/tag   "v0.8.4"
                                        :git/sha   "f096de8"
                                        :deps/root "projects/kaocha-wrapper"}}}
             :poly      {:jvm-opts   [
                                      ; Required for in-process XTDB
                                      "-Dpoly.test.jvm.opts=:jdm-opts"]
                         :main-opts  ["-m" "polylith.clj.core.poly-cli.core"]
                         :extra-deps {polylith/clj-poly {:mvn/version "0.2.19"}
                                      polylith-kaocha/test-runner
                                      {:git/url   ""
                                       :git/tag   "v0.8.4"
                                       :git/sha   "f096de8"
                                       :deps/root "projects/test-runner"}}}}
https://clojurians.slack.com/archives/C013B7MQHJQ/p1720646425592599?thread_ts=1720641367.046649&cid=C013B7MQHJQ

Nikolas Pafitis20:07:48

Running with clojure -M:poly test :dev

seancorfield20:07:46

Do you have another deftest transform--test in that file after the one you showed?

seancorfield20:07:03

(or even a def / defn of that symbol)

Nikolas Pafitis20:07:43

Nope the full file is:

(ns streamcraft.persistence-schema-transformer-malli-datomic.core-test
  (:require [clojure.test :refer [deftest is testing use-fixtures]]
            [com.stuartsierra.component :as component]
            [streamcraft.protocols.api.transformer.schema :as ts]
            [streamcraft.utils.test :refer :all]))

(def schemas {:simple-person [:map {:entity/name :simple-person}
                              [:simple-person/name :string]
                              [:simple-person/age :int]
                              [:simple-person/email [:re #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"]]
                              [:simple-person/active :boolean]]})

(use-fixtures :each (with-system-fixture
                      (component/system-map
                        :schemas schemas
                        :registry (component/using
                                    (fresh-entity-registry)
                                    [:schemas])
                        :transformer (component/using
                                       (fresh-malli-datomic-persistence-schema-transformer)
                                       [:registry]))))

(deftest transform--test
  (is (= 1 2))
  (testing "Transforming a simple schema to Datomic schema"
    (is (= 1 2))
    (let [{:keys [transformer]} *system*]
      (is (= [{:db/ident       :simple-person/name
               :db/valueType   :db.type/string
               :db/cardinality :db.cardinality/one
               :db/fulltext    true}
              {:db/ident       :simple-person/age
               :db/valueType   :db.type/long
               :db/cardinality :db.cardinality/one}
              {:db/ident       :simple-person/email
               :db/valueType   :db.type/string
               :db/cardinality :db.cardinality/one
               :db/fulltext    true}
              {:db/ident       :simple-person/active
               :db/valueType   :db.type/boolean
               :db/cardinality :db.cardinality/one}]
             (ts/transform transformer :simple-person))))))

Nikolas Pafitis20:07:09

Might be one of those apple silicon issues?

Nikolas Pafitis21:07:25

@seancorfield and the rest. It's my bad I have messed up the with-system-fixture, was never running the body.

seancorfield21:07:01

Ah, I see the bug...

(defmacro with-system [system body]
  `(binding [*system* (component/start-system ~system)]
     ~@body
     (component/stop-system *system*)))
should be
(defmacro with-system [system & body]
  `(binding [*system* (component/start-system ~system)]
     ~@body
     (component/stop-system *system*)))
otherwise ~@body unwinds the (f) list as just f

seancorfield21:07:04

That's a subtle one (and it took me a couple of attempts to debug things before I realized what was going on!).

Nikolas Pafitis16:07:37

I only realized that after i ran the tests with intellij and gotten the same result lol