scrubbed all reference to datomic.api
This commit is contained in:
@@ -1,55 +1,26 @@
|
||||
(ns auto-ap.integration.graphql.invoices
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn uri]]
|
||||
[auto-ap.datomic.migrate :as m]
|
||||
[auto-ap.time-reader]
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.graphql.invoices :as sut]
|
||||
[clj-time.core :as time]
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
||||
[datomic.api :as d]))
|
||||
|
||||
(defn wrap-setup
|
||||
[f]
|
||||
(with-redefs [auto-ap.datomic/uri "datomic:mem://datomic-transactor:4334/invoice"]
|
||||
(d/create-database uri)
|
||||
(with-redefs [auto-ap.datomic/conn (d/connect uri)]
|
||||
(m/migrate conn)
|
||||
|
||||
(f)
|
||||
(d/release conn)
|
||||
(d/delete-database uri))))
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn admin-token []
|
||||
{:user "TEST ADMIN"
|
||||
:exp (time/plus (time/now) (time/days 1))
|
||||
:user/role "admin"
|
||||
:user/name "TEST ADMIN"})
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn user-token [client-id]
|
||||
{:user "TEST USER"
|
||||
:exp (time/plus (time/now) (time/days 1))
|
||||
:user/role "user"
|
||||
:user/name "TEST USER"
|
||||
:user/clients [{:db/id client-id}]})
|
||||
|
||||
[auto-ap.integration.util :refer [admin-token wrap-setup]]
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]))
|
||||
|
||||
(use-fixtures :each wrap-setup)
|
||||
|
||||
(deftest test-add-invoice
|
||||
(testing "It should Add an invoice"
|
||||
(let [{:strs [vendor-id client-id account-id]}
|
||||
(:tempids @(d/transact conn [{:client/code "ABC"
|
||||
:db/id "client-id"
|
||||
:client/locations ["DT"]}
|
||||
{:vendor/name "Vendy"
|
||||
:db/id "vendor-id"
|
||||
:vendor/default-account "account-id"}
|
||||
{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/allowed
|
||||
:db/id "account-id"}]))]
|
||||
(:tempids (dc/transact conn
|
||||
{:tx-data [{:client/code "ABC"
|
||||
:db/id "client-id"
|
||||
:client/locations ["DT"]}
|
||||
{:vendor/name "Vendy"
|
||||
:db/id "vendor-id"
|
||||
:vendor/default-account "account-id"}
|
||||
{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/allowed
|
||||
:db/id "account-id"}]}))]
|
||||
(is (some? (sut/add-invoice {:id (admin-token)}
|
||||
{:invoice {:client_id client-id
|
||||
:vendor_id vendor-id
|
||||
@@ -62,11 +33,11 @@
|
||||
nil)))
|
||||
(testing "It should prevent an expense account that isn't allowed"
|
||||
(let [{:strs [denied-account-id]}
|
||||
(:tempids @(d/transact conn [
|
||||
{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/denied
|
||||
:db/id "denied-account-id"}]))]
|
||||
(:tempids (dc/transact conn
|
||||
{:tx-data [{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/denied
|
||||
:db/id "denied-account-id"}]}))]
|
||||
(is (thrown? Exception (sut/add-invoice {:id (admin-token)}
|
||||
{:invoice {:client_id client-id
|
||||
:vendor_id vendor-id
|
||||
@@ -80,15 +51,15 @@
|
||||
|
||||
(testing "It should allow an expense account that is valid for the vendor"
|
||||
(let [{:strs [vendor-account-id vendor-2]}
|
||||
(:tempids @(d/transact conn [
|
||||
{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/denied
|
||||
:account/vendor-allowance :allowance/allowed
|
||||
:db/id "vendor-account-id"}
|
||||
{:vendor/name "Testy"
|
||||
:vendor/default-account "vendor-account-id"
|
||||
:db/id "vendor-2"}]))]
|
||||
(:tempids (dc/transact conn {:tx-data [
|
||||
{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/denied
|
||||
:account/vendor-allowance :allowance/allowed
|
||||
:db/id "vendor-account-id"}
|
||||
{:vendor/name "Testy"
|
||||
:vendor/default-account "vendor-account-id"
|
||||
:db/id "vendor-2"}]}))]
|
||||
(is (some? (sut/add-invoice {:id (admin-token)}
|
||||
{:invoice {:client_id client-id
|
||||
:vendor_id vendor-2
|
||||
|
||||
Reference in New Issue
Block a user