yaml from/to-string
This commit is contained in:
parent
9b4d355fd7
commit
8919466f13
2 changed files with 12 additions and 4 deletions
|
@ -1,8 +1,11 @@
|
||||||
(ns dda.k8s-mastodon-bot.yaml
|
(ns dda.k8s-mastodon-bot.yaml
|
||||||
(:require
|
(:require
|
||||||
[aero.core :as aero]
|
|
||||||
["js-yaml" :as yaml]
|
["js-yaml" :as yaml]
|
||||||
))
|
))
|
||||||
|
|
||||||
(defn from-string [input]
|
(defn from-string [input]
|
||||||
42)
|
(js->clj (yaml/load input)
|
||||||
|
:keywordize-keys true))
|
||||||
|
|
||||||
|
(defn to-string [edn]
|
||||||
|
(yaml/dump (clj->js edn)))
|
|
@ -3,6 +3,11 @@
|
||||||
[clojure.test :refer [deftest is testing are]]
|
[clojure.test :refer [deftest is testing are]]
|
||||||
[dda.k8s-mastodon-bot.yaml :as cut]))
|
[dda.k8s-mastodon-bot.yaml :as cut]))
|
||||||
|
|
||||||
(deftest should-pars-yaml-string
|
(deftest should-parse-yaml-string
|
||||||
(is (= 43
|
(is (= {:hallo "welt"}
|
||||||
(cut/from-string "hallo: welt"))))
|
(cut/from-string "hallo: welt"))))
|
||||||
|
|
||||||
|
(deftest should-generate-yaml-string
|
||||||
|
(is (= "hallo: welt
|
||||||
|
"
|
||||||
|
(cut/to-string {:hallo "welt"}))))
|
||||||
|
|
Loading…
Reference in a new issue