Skip to content

Shorthand opts not used during factory generation #3

@camdez

Description

@camdez

The README indicates that the three variants used below are all equivalent, but the third (shorthand) version appears not to work:

(ns example1
  [lambdaisland.harvest :as h])

(h/defactory user
  {:user/name "Lilliam Predovic"})

[(h/build-val user {:with {:user/name "jill"}})
 (h/build-val (user :with {:user/name "jill"}))
 (h/build-val (user {:user/name "jill"}))]

;; => [#:user{:name "jill"}
;;     #:user{:name "jill"}
;;     #:user{:name "Lilliam Predovic"}]

The same issue occurs (perhaps unsurprisingly) when the call is inlined into another factory:

(ns example2
  [lambdaisland.harvest :as h])

(h/defactory user
  {:user/name "Lilliam Predovic"})

(h/defactory article
  {:article/submitter (user {:user/name "jill"})})

(h/build-val article) ; => #:article{:submitter #:user{:name "Lilliam Predovic"}}

Just my 2¢, but I'm not really convinced all these variants need to exist—and could just lead to user confusion / limit further evolution of the API—but, as described, something is amiss in either the docs or the code.


I really like what you're doing with this library! I'm still sussing out best practices, but I look forward to using Harvest to remove a bunch of boilerplate in our tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions