Comments (10)
Sorry, I don't understand what you're asking.
You've created a failing test, and Midje tells you that it's failed. Is there some additional information in the failure message that you expect to see?
from integrant.
My bad, I should have been more specific. My expectation was that the test should pass as written, but instead the metaconstant is turned into an empty map. I'm trying to look around to see where this would happen.
I noticed that the config's ::origin metadata does retain the metaconstant as given:
{:integrant.core/build {:some/component {:config-key {}}}
:integrant.core/origin {:some/component {:config-key ..value..}}}
from integrant.
er, sorry, I see your confusion now better. The fact that my init-key method doesn't actually return anything useful is seemingly incidental to the problem of metaconstants disappearing. I'll try to come up with a better example
from integrant.
Your init-key
method for :some/component
returns nil
, so running init
will produce:
{:some/component nil}
This seems in line with the failure message you're getting.
from integrant.
Here, this is more what I'm getting at:
(defmethod ig/init-key :some/component
[_ config]
(:config-key config))
(fact
(ig/init {:some/component {:config-key ..value..}})
=> {:some/component ..value..})
Produces:
Error Metaconstants (..value..) can't be compared for equality with {}.
Whereas the following passes:
(fact
(ig/init {:some/component {:config-key "value"}})
=> {:some/component "value"})
from integrant.
Isn't this a problem with Midje? Integrant doesn't produce anything unusual; the output of init
is an immutable map with some metadata attached to provide halt ordering.
from integrant.
I'm really not sure. In practice, my init-key and halt-key! multimethods all only have a single call to an external function that handles all the config destructuring and logic. So since Midje works just fine with those regular functions, my test coverage probably probably doesn't need to include my Integrant multimethods.
I just thought it was strange that the metaconstants would behave this way when passed through ig/init.
Stranger yet, even if you put the defmethod inside of a fact macro, this still happens.
Seems like a limitation that could be avoided somehow, but I'm not sure if I should be asking you or @marick
from integrant.
I don't think this is an issue with Integrant. init
is a function that takes in a map and returns a map with metadata - there's nothing particularly unusual about it, and a test library should be able to handle that. I'd suggest opening this issue on the Midje project.
from integrant.
Alright, I'll do that. Thank you!
from integrant.
Well, it seems the issue is not easily fixed (if it's even possible to fix it). I still don't understand why this is happening, but I'll just give up and work around it.
from integrant.
Related Issues (20)
- Uninitialized/literal configs HOT 1
- Tests don't run with 1.11 due to clojure.test/run-test already being defined HOT 1
- Feature proposal: expand-key HOT 2
- Any way to add constant key in `edn`? HOT 2
- ClojureScript support for `read-string` HOT 4
- Initialisation Order HOT 5
- Deprecate :include-refsets? in favor of :include-reflikes? HOT 16
- Decouple top-level keys from configuration type definitions HOT 9
- [Feature] Ability to provide custom hierarchy to `init` method HOT 6
- Would you consider an integrant2 to support extensible build steps? HOT 10
- Why does resume halt unspecified system keys? HOT 4
- Support usage in Babashka environments HOT 20
- #{:idea} Pass the spec validations step on all defined states before calling init-key. HOT 1
- is it possible to access a component after it's init-key, but before it gets passed to the next key that depends on it? HOT 2
- Enter Integrant Video
- Add support for custom assertf definitions HOT 2
- Question: Extract "validation keys" logic from core/build implementation HOT 4
- Feature request: pre-init hook
- No method in multimethod 'init-key' for dispatch value HOT 2
- #ig/ref should allow for deep references HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from integrant.