Skip to content

Instantly share code, notes, and snippets.

@256BitChris
Created March 9, 2018 23:39
Show Gist options
  • Save 256BitChris/b7623d37f4856d888d8da55c3452def9 to your computer and use it in GitHub Desktop.
Save 256BitChris/b7623d37f4856d888d8da55c3452def9 to your computer and use it in GitHub Desktop.
(defn-spec eligible-to-create-subscription? boolean?
"Is the subscription eligible for creating a new one?"
[subscription (s/keys :req [::subscription-status])]
(case (-> ::subscription-status subscription)
(::expired ::canceled ::free-trial ::free-trial-expired) true
false))
(s/exercise-fn `eligible-to-create-subscription?)
=>
([(#:io.cloudrepo.payments{:subscription-status :io.cloudrepo.payments/free-trial-expired}) true]
[(#:io.cloudrepo.payments{:subscription-status :io.cloudrepo.payments/free-trial-expired}) true]
[(#:io.cloudrepo.payments{:subscription-status :io.cloudrepo.payments/active}) false]
[(#:io.cloudrepo.payments{:subscription-status :io.cloudrepo.payments/pending}) false]
[(#:io.cloudrepo.payments{:subscription-status :io.cloudrepo.payments/expired}) true]
[(#:io.cloudrepo.payments{:subscription-status :io.cloudrepo.payments/cancelled}) false]
[(#:io.cloudrepo.payments{:subscription-status :io.cloudrepo.payments/free-trial}) true]
[(#:io.cloudrepo.payments{:subscription-status :io.cloudrepo.payments/expired}) true]
[(#:io.cloudrepo.payments{:subscription-status :io.cloudrepo.payments/past-due}) false]
[(#:io.cloudrepo.payments{:subscription-status :io.cloudrepo.payments/pending}) false])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment