juspay / fencer

Fencer is a port of https://github.com/lyft/ratelimit into Haskell.
https://hub.docker.com/r/juspayin/fencer
Other
9 stars 2 forks source link

Test that descriptor key can not be empty #95

Open neongreen opened 5 years ago

neongreen commented 5 years ago

https://github.com/lyft/ratelimit/blob/master/test/config/config_test.go#L185-L194

mdimjasevic commented 4 years ago

While it would be possible to test this, I'd argue there is not much point in this because the test would hold vacuously. We have this guarantee from Haskell's type checker. This is the definition of the descriptor:

https://github.com/juspay/fencer/blob/8d627af01fb9cf3d8cef000c6e9612f08818c2b9/lib/Fencer/Types.hs#L154-L161

and this is its FromJSON instance:

https://github.com/juspay/fencer/blob/8d627af01fb9cf3d8cef000c6e9612f08818c2b9/lib/Fencer/Types.hs#L177-L183

In other words, key has to be there, otherwise we get an exception like this:

2019-11-27T16:39:31Z, E, error loading new configuration from runtime: "nix/ratelimit/ratelimit/config/another.yaml", Aeson exception:
Error in $.descriptors[0].key: parsing Text failed, expected String, but encountered Null
mdimjasevic commented 4 years ago

@neongreen: Can I close this issue?