From aac520932279b83515ced65aadb24dc2f2bedde7 Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 19 Oct 2022 09:18:44 +0200 Subject: [PATCH 1/3] add .clj-kondo and .lsp --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index ca00915..7616f34 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ public/js/ valid-auth.edn valid-config.edn my-auth.edn + +.clj-kondo/ +.lsp/ From e6074cdb4d975b3708595452d4f907e8673f8c18 Mon Sep 17 00:00:00 2001 From: Clemens Date: Fri, 28 Oct 2022 12:42:19 +0200 Subject: [PATCH 2/3] Added integer-string? predicate --- src/main/cljc/dda/c4k_common/predicate.cljc | 6 ++++++ src/test/cljc/dda/c4k_common/predicate_test.cljc | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/cljc/dda/c4k_common/predicate.cljc b/src/main/cljc/dda/c4k_common/predicate.cljc index c76e9b5..da55f18 100644 --- a/src/main/cljc/dda/c4k_common/predicate.cljc +++ b/src/main/cljc/dda/c4k_common/predicate.cljc @@ -44,6 +44,12 @@ (fqdn-string? (first split-string)) (port-number? (edn/read-string (second split-string))))))) +(defn integer-string? + [input] + (and (string? input) + (some? (re-matches #"^\d+$" input)) + (integer? (edn/read-string input)))) + (defn string-sequence? [input] (and (sequential? input) diff --git a/src/test/cljc/dda/c4k_common/predicate_test.cljc b/src/test/cljc/dda/c4k_common/predicate_test.cljc index c91bb19..4ae1251 100644 --- a/src/test/cljc/dda/c4k_common/predicate_test.cljc +++ b/src/test/cljc/dda/c4k_common/predicate_test.cljc @@ -51,6 +51,15 @@ (is (false? (cut/host-and-port-string? "test.123:1234"))) (is (false? (cut/host-and-port-string? "test.de:abc")))) +(deftest test-integer-string? + (is (true? (cut/integer-string? "1"))) + (is (true? (cut/integer-string? "42"))) + (is (false? (cut/integer-string? 42))) + (is (false? (cut/integer-string? "42.2"))) + (is (false? (cut/integer-string? "4 2"))) + (is (false? (cut/integer-string? "1e2"))) + (is (false? (cut/integer-string? true)))) + (deftest test-string-sequence? (is (true? (cut/string-sequence? ["hallo" "welt" "!"]))) (is (false? (cut/string-sequence? ["hallo" 1 "welt" "!"]))) From ef9fd8ea65835bf2f44faa62b671cb7d91388bcd Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 2 Nov 2022 13:58:20 +0100 Subject: [PATCH 3/3] Fix test and update deps * Exception testing now happens for clj only * If testing for cljs is required we need tests for cljs --- package.json | 62 +++++++++---------- src/test/cljc/dda/c4k_common/common_test.cljc | 19 +++--- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index 904966a..158d3d4 100644 --- a/package.json +++ b/package.json @@ -1,32 +1,32 @@ { - "name": "c4k-common-cljs", - "description": "Contains predicates and tools for c4k", - "author": "meissa GmbH", - "version": "0.2.0-SNAPSHOT", - "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-common#readme", - "repository": "https://www.npmjs.com/package/c4k-common", - "license": "APACHE2", - "main": "c4k-common.js", - "bin": { - "c4k-common": "./c4k-common.js" - }, - "keywords": [ - "cljs", - "k8s", - "c4k", - "deployment", - "yaml", - "convention4kubernetes" - ], - "bugs": { - "url": "https://gitlab.com/domaindrivenarchitecture/c4k-common/issues" - }, - "dependencies": { - "js-base64": "^3.6.1", - "js-yaml": "^4.0.0" - }, - "devDependencies": { - "shadow-cljs": "^2.11.18", - "source-map-support": "^0.5.19" - } -} + "name": "c4k-common-cljs", + "description": "Contains predicates and tools for c4k", + "author": "meissa GmbH", + "version": "0.2.0-SNAPSHOT", + "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-common#readme", + "repository": "https://www.npmjs.com/package/c4k-common", + "license": "APACHE2", + "main": "c4k-common.js", + "bin": { + "c4k-common": "./c4k-common.js" + }, + "keywords": [ + "cljs", + "k8s", + "c4k", + "deployment", + "yaml", + "convention4kubernetes" + ], + "bugs": { + "url": "https://gitlab.com/domaindrivenarchitecture/c4k-common/issues" + }, + "dependencies": { + "js-base64": "^3.7.2", + "js-yaml": "^4.0.0" + }, + "devDependencies": { + "shadow-cljs": "^2.11.18", + "source-map-support": "^0.5.19" + } +} \ No newline at end of file diff --git a/src/test/cljc/dda/c4k_common/common_test.cljc b/src/test/cljc/dda/c4k_common/common_test.cljc index e0f6d36..7bdaeb5 100644 --- a/src/test/cljc/dda/c4k_common/common_test.cljc +++ b/src/test/cljc/dda/c4k_common/common_test.cljc @@ -15,12 +15,13 @@ (is (= ["a1" "a2" "b1"] (cut/concat-vec '("a1" "a2") '("b1"))))) -(deftest should-refuse-illegal-inputs - (is (thrown? Exception - (cut/concat-vec ["a1" "a2"] "b1"))) - (is (thrown? Exception - (cut/concat-vec ["a1" "a2"] nil))) - (is (thrown? Exception - (cut/concat-vec ["a1" "a2"] 2))) - (is (thrown? Exception - (cut/concat-vec {"a1" "a2"} [])))) \ No newline at end of file +#?(:clj + (deftest should-refuse-illegal-inputs + (is (thrown? Exception + (cut/concat-vec ["a1" "a2"] "b1"))) + (is (thrown? Exception + (cut/concat-vec ["a1" "a2"] nil))) + (is (thrown? Exception + (cut/concat-vec ["a1" "a2"] 2))) + (is (thrown? Exception + (cut/concat-vec {"a1" "a2"} [])))))