diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-01 13:19:41 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-01 15:56:45 -0700 |
commit | 7174cca4f9fe09271bc9b4bf3ce7ecc2b4fe1639 (patch) | |
tree | a75f2816a8d6a135623253a78d929e9070d3982c | |
parent | f24d52fba8f53ad9d605f974ecb00161b5380824 (diff) | |
download | consfigurator-7174cca4f9fe09271bc9b4bf3ce7ecc2b4fe1639.tar.gz |
add some tests for new conf file properties
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | consfigurator.asd | 16 | ||||
-rw-r--r-- | tests/package.lisp | 5 | ||||
-rw-r--r-- | tests/property/file.lisp | 76 |
3 files changed, 96 insertions, 1 deletions
diff --git a/consfigurator.asd b/consfigurator.asd index 7a78744..102b34a 100644 --- a/consfigurator.asd +++ b/consfigurator.asd @@ -51,4 +51,18 @@ (:file "src/data/asdf") (:file "src/data/pgp") (:file "src/data/git-snapshot") - (:file "src/data/gpgpubkeys"))) + (:file "src/data/gpgpubkeys")) + :in-order-to ((test-op (test-op "consfigurator/tests")))) + +(defsystem "consfigurator/tests" + :description + "Tests for Consfigurator, Lisp declarative configuration management system" + :version "0.3.1" + :author "Sean Whitton <spwhitton@spwhitton.name>" + :licence "GPL-3+" + :serial t + :depends-on (#:consfigurator + #+sbcl #:sb-rt #-sbcl #:rt) + :components ((:file "tests/package") + (:file "tests/property/file")) + :perform (test-op (o c) (symbol-call :consfigurator/tests '#:do-tests))) diff --git a/tests/package.lisp b/tests/package.lisp new file mode 100644 index 0000000..286243c --- /dev/null +++ b/tests/package.lisp @@ -0,0 +1,5 @@ +(in-package :cl-user) + +(defpackage :consfigurator/tests + (:use #:cl #:consfigurator #+sbcl :sb-rt #-sbcl :rtest) + (:local-nicknames (#:file #:consfigurator.property.file))) diff --git a/tests/property/file.lisp b/tests/property/file.lisp new file mode 100644 index 0000000..10a20b1 --- /dev/null +++ b/tests/property/file.lisp @@ -0,0 +1,76 @@ +(in-package :consfigurator/tests) +(named-readtables:in-readtable :consfigurator) +(in-consfig "consfigurator/tests") + +(deftest contains-conf-space + (with-temporary-file (:pathname temp) + (with-open-file (s temp :if-exists :supersede :direction :output) + (write-sequence #>EOF>foo bar + +# one two +one three +# one three +EOF s)) + (with-local-connection + (file:contains-conf-space temp "foo" "baz" "one" "four" "two" "five")) + (read-file-string temp)) + #>EOF>foo baz + +one four +# one three +# one three +two five +EOF) + +(deftest contains-conf-shell + (with-temporary-file (:pathname temp) + (with-open-file (s temp :if-exists :supersede :direction :output) + (write-sequence #>EOF>foo="bar baz" + +# bar=baz +other="three word s" +EOF s)) + (with-local-connection + (file:contains-conf-shell + temp "bar" "two words" "quux" "one" "other" "one")) + (read-file-string temp)) + #>EOF>foo="bar baz" + +bar="two words" +other=one +quux=one +EOF) + +(deftest contains-ini-settings + (with-temporary-file (:pathname temp) + (with-open-file (s temp :if-exists :supersede :direction :output) + (write-sequence #>EOF>[one] +two=three + +[other] +; bar = ba +bar = baz baz quux +EOF s)) + (with-local-connection + (file:contains-ini-settings temp + '("one" "four" "five") + '("another" "k" "v") + '("other" "bar" "baz") + '("another" "key" "val") + '("finally" "this" "one"))) + (read-file-string temp)) + #>EOF>[one] +two=three +four=five + +[other] +bar=baz +# bar=baz baz quux + +[another] +k=v +key=val + +[finally] +this=one +EOF) |