Created
August 7, 2020 21:29
-
-
Save manish-2014/9ee4f5caca8685122fe1c3119be4e8a3 to your computer and use it in GitHub Desktop.
me.vedang/clj-fdb bug report
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns fdb-poc.core-test | |
(:import [java.util Calendar TimeZone] | |
[com.apple.foundationdb Database] | |
) | |
(:require [clojure.test :refer :all] | |
[clojure.string :as str] | |
[byte-streams :as bs] | |
[me.vedang.clj-fdb.FDB :as cfdb] | |
[me.vedang.clj-fdb.core :as fc] | |
[me.vedang.clj-fdb.tuple.tuple :as ftup] | |
) | |
) | |
(def test-prefix "tests") | |
(defn- my-test-fixture | |
"Helper fn to ensure sanity of DB" | |
[f] | |
(let [fdb (cfdb/select-api-version cfdb/clj-fdb-api-version) | |
rg (ftup/range (ftup/from test-prefix))] | |
(with-open [^Database db (cfdb/open fdb)] | |
(fc/clear-range db rg))) | |
(f) | |
) | |
(use-fixtures :once my-test-fixture) | |
(def not-nil? (complement nil?)) | |
(deftest a-test | |
(testing "string set get test." | |
(let [ | |
value-to-store "really important stuff" | |
key-tpl (ftup/from "level1" "level2" "level3") | |
val-tpl (ftup/from value-to-store) | |
_ (let [fdb (cfdb/select-api-version cfdb/clj-fdb-api-version)] | |
(with-open [db (cfdb/open fdb)] (fc/set db key-tpl val-tpl))) | |
val-from-fdb (let [fdb (cfdb/select-api-version cfdb/clj-fdb-api-version)] | |
(with-open [db (cfdb/open fdb)] (fc/get db key-tpl :valfn #(bs/convert % String)))) | |
] | |
(is (= val-from-fdb value-to-store)) | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment