728x90
guestbook 튜토리얼을 진행하는 중 마지막 테스트 단계에서 아래의 실패 메시지가 나오는 경우를 만날 수 있다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ~/guestbook$ lein test 2018-08-23 08:21:32,895 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider lein test guestbook.test.db.core 2018-08-23 08:21:34,884 [main] INFO migratus.core - Starting migrations 2018-08-23 08:21:34,909 [main] INFO migratus.database - creating migration table 'schema_migrations' 2018-08-23 08:21:34,965 [main] DEBUG migratus.migrations - Looking for migrations in #object[java.io.File 0x5244b461 /home/fukaerii/guestbook/resources/migrations] 2018-08-23 08:21:34,968 [main] WARN migratus.migrations - skipping: '20180821033932-add-users-table.up.sqles' migrations must match pattern: ^(\d+)-([^\.]+)((?:\.[^\.]+)+)$ 2018-08-23 08:21:34,983 [main] INFO migratus.core - Running up for [20180821033932] 2018-08-23 08:21:34,985 [main] INFO migratus.core - Up 20180821033932-add-users-table 2018-08-23 08:21:35,013 [main] DEBUG migratus.migration.sql - found 1 up migrations 2018-08-23 08:21:35,022 [main] DEBUG migratus.database - marking 20180821033932complete 2018-08-23 08:21:35,036 [main] INFO migratus.core - Ending migrations lein test :only guestbook.test.db.core/test-message FAIL in (test-message) (core.clj:27) expected: {:name "test", :message "test", :timestamp #inst "2018-08-23T08:21:35.045-00:00"} actual: {:name "test", :message "test", :timestamp #object[org.joda.time.DateTime 0x5effdc4d "2018-08-23T08:21:35.045Z"]} diff: - {:timestamp #inst "2018-08-23T08:21:35.045-00:00"} + {:timestamp #object[org.joda.time.DateTime 0x5effdc4d "2018-08-23T08:21:35.045Z"]} lein test guestbook.test.handler Ran 2 tests containing 6 assertions. 1 failures, 0 errors. Tests failed. | cs |
다음과 같이 아래 파일을 수정한다.
/home/fukaerii/guestbook/test/clj/guestbook/test/db/core.clj
[수정전]
1 2 3 4 5 6 7 8 9 10 11 | (deftest test-message (jdbc/with-db-transaction [t-conn *db*] (jdbc/db-set-rollback-only! t-conn) (let [message {:name "test" :message "test" :timestamp (java.util.Date.)}] (is (= 1 (db/save-message! t-conn message))) (let [result (db/get-messages t-conn {})] (is (= 1 (count result))) (is (= message (dissoc (first result) :id)))))) (is (empty? (db/get-messages)))) | cs |
[수정후]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | (deftest test-message (jdbc/with-db-transaction [t-conn *db*] (jdbc/db-set-rollback-only! t-conn) (let [timestamp (org.joda.time.DateTime. org.joda.time.DateTimeZone/UTC)] (is (= 1 (db/save-message! t-conn {:name "Bob" :message "Hello, World" :timestamp timestamp} {:connection t-conn}))) (is (= {:name "Bob" :message "Hello, World" :timestamp timestamp} (-> (db/get-messages t-conn {}) (first) (select-keys [:name :message :timestamp]))))))) | cs |
수정 후 다시 테스트해보면 오류없이 실행됨을 알 수 있다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | ~/guestbook$ lein test-refresh 2018-08-23 08:26:14,305 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider ********************************************* *************** Running tests *************** :reloading (guestbook.dev-middleware guestbook.config guestbook.db.core guestbook.env guestbook.layout guestbook.middleware guestbook.routes.home guestbook.handler guestbook.nrepl guestbook.core guestbook.test.handler user guestbook.test.db.core) Testing guestbook.test.db.core 2018-08-23 08:26:17,027 [main] INFO migratus.core - Starting migrations 2018-08-23 08:26:17,087 [main] DEBUG migratus.migrations - Looking for migrations in #object[java.io.File 0x55b0d752 /home/fukaerii/guestbook/resources/migrations] 2018-08-23 08:26:17,093 [main] WARN migratus.migrations - skipping: '20180821033932-add-users-table.up.sqles' migrations must match pattern: ^(\d+)-([^\.]+)((?:\.[^\.]+)+)$ 2018-08-23 08:26:17,097 [main] INFO migratus.core - Ending migrations FAIL in (test-message) (core.clj:27) expected: {:name "test", :message "test", :timestamp #inst "2018-08-23T08:26:17.117-00:00"} actual: {:name "test", :message "test", :timestamp #object[org.joda.time.DateTime 0x39aef4b8 "2018-08-23T08:26:17.117Z"]} diff: - {:timestamp #inst "2018-08-23T08:26:17.117-00:00"} + {:timestamp #object[org.joda.time.DateTime 0x39aef4b8 "2018-08-23T08:26:17.117Z"]} Testing guestbook.test.handler Ran 2 tests containing 6 assertions. 1 failures, 0 errors. Failed 1 of 6 assertions Finished at 08:26:17.745 (run time: 1.693s) ********************************************* *************** Running tests *************** :reloading (guestbook.test.db.core) Testing guestbook.test.db.core 2018-08-23 08:32:20,405 [main] INFO migratus.core - Starting migrations 2018-08-23 08:32:20,427 [main] DEBUG migratus.migrations - Looking for migrations in #object[java.io.File 0x4798dff0 /home/fukaerii/guestbook/resources/migrations] 2018-08-23 08:32:20,429 [main] WARN migratus.migrations - skipping: '20180821033932-add-users-table.up.sqles' migrations must match pattern: ^(\d+)-([^\.]+)((?:\.[^\.]+)+)$ 2018-08-23 08:32:20,433 [main] INFO migratus.core - Ending migrations Testing guestbook.test.handler Ran 2 tests containing 4 assertions. 0 failures, 0 errors. Passed all tests Finished at 08:32:20.448 (run time: 0.110s) | cs |
728x90
'프로그래밍 Programming' 카테고리의 다른 글
Go 프로그램 설치 및 테스트 Install the Go tools (0) | 2018.08.24 |
---|---|
Luminus 를 이용한 Clojure 방명록 만들기 (5) - 테스트 및 패키지화 (0) | 2018.08.23 |
Luminus 를 이용한 Clojure 방명록 만들기 (4) - 페이지 생성 및 폼입력 다루기 (0) | 2018.08.23 |
Luminus 를 이용한 Clojure 방명록 만들기 (3) - 어플리케이션 구동 (0) | 2018.08.21 |
Luminus 를 이용한 Clojure 방명록 만들기 (2) - H2 데이터베이스 생성 및 접근 (0) | 2018.08.21 |