Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
AE-2036: Test that aineistot are actually generated
Browse files Browse the repository at this point in the history
  • Loading branch information
solita-juhohaa committed Dec 7, 2023
1 parent 22f436d commit 6c47f60
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions etp-backend/src/test/clj/solita/etp/service/aineisto_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,21 @@
(.plusSeconds 86400))
actual-ip])
(t/is (true? (aineisto/check-access ts/*db*, user-id-with-allowed-ip, allowed-aineisto-type, actual-ip)))))

(t/deftest update-aineistot-test
(let []
(t/testing "Aineistot don't exist before generating"
(t/is (not (solita.etp.service.file/file-exists? ts/*aws-s3-client* "/aineistot/1/energiatodistukset.csv")))
(t/is (not (solita.etp.service.file/file-exists? ts/*aws-s3-client* "/aineistot/2/energiatodistukset.csv")))
(t/is (not (solita.etp.service.file/file-exists? ts/*aws-s3-client* "/aineistot/3/energiatodistukset.csv"))))
(t/testing "Aineistot exist after generating"
(aineisto/update-aineistot-in-s3! ts/*db* {:id -5 :rooli 2} ts/*aws-s3-client*)
(t/is (solita.etp.service.file/file-exists? ts/*aws-s3-client* "/aineistot/1/energiatodistukset.csv"))
(t/is (solita.etp.service.file/file-exists? ts/*aws-s3-client* "/aineistot/2/energiatodistukset.csv"))
(t/is (solita.etp.service.file/file-exists? ts/*aws-s3-client* "/aineistot/3/energiatodistukset.csv")))
#_(t/testing "Adding some new energiatodistus has an effect on the aineistot"
;;TODO: Could get object size via GetObjectAttributes request parameter `x-amz-object-attributes ObjectSize`
;; and look that the size increases when energiatodistus is added and aineistot generated again.
;; Might be too heavy of an operation and takes time to implement.
(aineisto/update-aineistot-in-s3! ts/*db* {:id -5 :rooli 2} ts/*aws-s3-client*)
)))

0 comments on commit 6c47f60

Please sign in to comment.