Skip to content

Commit f50926d

Browse files
committed
HTTP tests with nginx
1 parent 9403c07 commit f50926d

File tree

7 files changed

+38
-50
lines changed

7 files changed

+38
-50
lines changed

docker-compose.yml

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
services:
2+
http:
3+
image: nginx:1.27.4
4+
ports:
5+
- "8080:80"
6+
volumes:
7+
- ./docker/http:/usr/share/nginx/html
8+
29
ftp:
310
image: crazymax/pure-ftpd:1.0.50
411
ports:

docker/http/test.png

12.4 KB
Loading

docker/http/test.png.bz2

11.8 KB
Binary file not shown.

docker/http/test.png.gz

11.3 KB
Binary file not shown.

test/cavia/core_test.clj

+29-14
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,35 @@
66

77
(defprofile test-prof
88
{:resources [{:id :test-resource
9-
:url "https://s3.amazonaws.com/cavia/test.png"
9+
:url "http://localhost:8080/test.png"
1010
:sha1 "07dba3bd9f227f58134d339b1609e0a913abe0de"}
1111
{:id :test-resource2
12-
:url "https://s3.amazonaws.com/cavia/test.png"
12+
:url "http://localhost:8080/test.png"
1313
:sha1 "unverifiedsha1"}
1414
{:id :test-resource3
15-
:url "https://s3.amazonaws.com/cavia/test.png"
15+
:url "http://localhost:8080/test.png"
1616
:md5 "0656b409231ee9bd8c5c9272647c69a1"}
1717
{:id :test-resource4
18-
:url "https://s3.amazonaws.com/cavia/test.png"
18+
:url "http://localhost:8080/test.png"
1919
:sha256 "55902cd4056e2bd57ced9296c826e4df42f07457c96ce72afe8652d0d6dd89b3"}
2020
{:id :test-resource-gzip
21-
:url "https://s3.amazonaws.com/cavia/test.png.gz"
21+
:url "http://localhost:8080/test.png.gz"
2222
:sha1 "07dba3bd9f227f58134d339b1609e0a913abe0de"
2323
:packed :gzip}
2424
{:id :test-resource-bzip2
25-
:url "https://s3.amazonaws.com/cavia/test.png.bz2"
25+
:url "http://localhost:8080/test.png.bz2"
2626
:sha1 "07dba3bd9f227f58134d339b1609e0a913abe0de"
27-
:packed :bzip2}]})
27+
:packed :bzip2}
28+
{:id :test-resource-ftp
29+
:url "ftp://localhost:2221/test.png"
30+
:sha1 "07dba3bd9f227f58134d339b1609e0a913abe0de"
31+
:auth {:user "user" :password "password"}}
32+
{:id :test-resource-s3
33+
:url "http://localhost:9000/cavia/test.png"
34+
:sha1 "07dba3bd9f227f58134d339b1609e0a913abe0de"
35+
:protocol :s3
36+
:auth {:access-key-id "minioadmin"
37+
:secret-access-key "minioadmin"}}]})
2838

2939
;;;
3040
;;; Setup and teardown
@@ -44,30 +54,35 @@
4454
;;; Tests
4555
;;;
4656

47-
(deftest resource-test
57+
(deftest ^:integration resource-test
4858
(testing "returns the resource's path"
4959
(is (not (nil? (re-find #".*\.cavia/test-resource$" (cavia/resource :test-resource))))))
5060
(testing "return path is absolute"
5161
(is (.isAbsolute (io/file (cavia/resource :test-resource)))))
5262
(testing "returns nil when the id does not exist"
5363
(is (nil? (cavia/resource :notexist)))))
5464

55-
(deftest exist?-test
65+
(deftest ^:integration exist?-test
5666
(testing "returns true if the file is already downloaded"
57-
(is (cavia/exist? :test-resource)))
67+
(are [k] (true? (cavia/exist? k))
68+
:test-resource
69+
:test-resource-ftp
70+
:test-resource-s3))
5871
(testing "returns false if the file is not downloaded"
5972
(is (not (cavia/exist? :test-resource2)))))
6073

61-
(deftest valid?-test
74+
(deftest ^:integration valid?-test
6275
(testing "returns true if the file's hash is valid"
63-
(are [k] (cavia/valid? k)
76+
(are [k] (true? (cavia/valid? k))
6477
:test-resource
6578
:test-resource3
66-
:test-resource4))
79+
:test-resource4
80+
:test-resource-ftp
81+
:test-resource-s3))
6782
(testing "returns false if the file's hash is invalid"
6883
(is (not (cavia/valid? :test-resource2)))))
6984

70-
(deftest packed-test
85+
(deftest ^:integration packed-test
7186
(testing "gzip"
7287
(is (cavia/exist? :test-resource-gzip))
7388
(is (cavia/valid? :test-resource-gzip)))

test/cavia/downloader_test.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
;;; defs
2323
;;;
2424

25-
(def http-test-url "https://s3.amazonaws.com/cavia/test.png")
25+
(def http-test-url "http://localhost:8080/test.png")
2626
(def http-test-hash "07dba3bd9f227f58134d339b1609e0a913abe0de")
2727
(def http-test-local (str temp-dir "/http-test-resource"))
2828

@@ -44,7 +44,7 @@
4444
;;; Tests
4545
;;;
4646

47-
(deftest http-download!-test
47+
(deftest ^:integration http-download!-test
4848
(testing "returns nil when finishing successfully "
4949
(is (nil? (dl/http-download! http-test-url http-test-local))))
5050
(testing "check the resource's hash"

test/cavia/integration_test.clj

-34
This file was deleted.

0 commit comments

Comments
 (0)