From 5ba08cbf2c82a97b4ce55fe637465e61d5088215 Mon Sep 17 00:00:00 2001 From: aronerben Date: Mon, 15 Aug 2022 19:59:16 +0200 Subject: [PATCH 1/4] Rename and fix unit test target --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7ed369e..765e2ef 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,6 @@ build: clean: opam exec -- dune clean -.PHONY: test-all -test-all: - curl -s -d '{ "requestor": "letters", "version": "0.1.0" }' "https://api.nodemailer.com/user" -X POST -H "Content-Type: application/json" > ethereal_account.json +.PHONY: test +test: opam exec -- dune runtest --force --no-buffer test From d24f718127f24f64a44027ce643a12304766790d Mon Sep 17 00:00:00 2001 From: aronerben Date: Mon, 15 Aug 2022 20:02:28 +0200 Subject: [PATCH 2/4] Remove lwt dependency in unit tests, add alcotest --- .github/workflows/ci.yml | 1 + test/dune | 7 +------ test/test.ml | 44 ++++++++++++++++++---------------------- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8929b52..7cb373f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,7 @@ jobs: run: | opam install -y dune opam install -y . --deps-only --with-doc --with-test --locked --unlock-base + opam install -y alcotest - name: Recover from an Opam broken state if: steps.cache-opam.outputs.cache-hit == 'true' run: opam upgrade --fixup diff --git a/test/dune b/test/dune index 33ba60e..dbf30fa 100644 --- a/test/dune +++ b/test/dune @@ -1,13 +1,8 @@ (executable (name test) - (libraries letters alcotest alcotest-lwt lwt)) + (libraries letters alcotest)) (rule (alias runtest) (action (run ./test.exe))) - -(rule - (alias runtest-all) - (action - (run ./test.exe))) diff --git a/test/test.ml b/test/test.ml index 86ae248..0b4ad73 100644 --- a/test/test.ml +++ b/test/test.ml @@ -12,7 +12,7 @@ let stream_to_string s = go () ;; -let test_create_plain_text_email _ () = +let test_create_plain_text_email _ = let recipients = [ To "dave@example.com" ] in let subject = "Hello" in let body = Plain "Hello Dave" in @@ -23,10 +23,10 @@ let test_create_plain_text_email _ () = | Error reason -> failwith reason in let message = stream_to_string stream in - Lwt.return (print_string message) + print_string message ;; -let test_create_html_email _ () = +let test_create_html_email _ = let recipients = [ To "dave@example.com" ] in let subject = "Hello" in let body = Html "Hello Dave" in @@ -37,10 +37,10 @@ let test_create_html_email _ () = | Error reason -> failwith reason in let message = stream_to_string stream in - Lwt.return (print_string message) + print_string message ;; -let test_create_mixed_body_email _ () = +let test_create_mixed_body_email _ = let recipients = [ To "dave@example.com" ] in let subject = "Hello" in let body = Mixed ("Hello Dave", "Hello Dave", Some "blaablaa") in @@ -51,26 +51,22 @@ let test_create_mixed_body_email _ () = | Error reason -> failwith reason in let message = stream_to_string stream in - Lwt.return (print_string message) + print_string message ;; let () = - Lwt_main.run - (Alcotest_lwt.run - "Email creation" - [ ( "Generating body" - , [ Alcotest_lwt.test_case - "email with plain text body" - `Quick - test_create_plain_text_email - ; Alcotest_lwt.test_case - "email with HTML text body" - `Quick - test_create_html_email - ; Alcotest_lwt.test_case - "email with mixed plain text and HTML body" - `Quick - test_create_mixed_body_email - ] ) - ]) + Alcotest.run + "Email creation" + [ ( "Generating body" + , [ Alcotest.test_case + "email with plain text body" + `Quick + test_create_plain_text_email + ; Alcotest.test_case "email with HTML text body" `Quick test_create_html_email + ; Alcotest.test_case + "email with mixed plain text and HTML body" + `Quick + test_create_mixed_body_email + ] ) + ] ;; From 796b4c49b534cdedcbcd0a95c4ac047e985c2573 Mon Sep 17 00:00:00 2001 From: aronerben Date: Mon, 15 Aug 2022 20:28:34 +0200 Subject: [PATCH 3/4] Remove CI cache --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cb373f..ed404ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,6 @@ jobs: with: ocaml-version: ${{ matrix.ocaml-version }} - name: Install dependencies - if: steps.cache-opam.outputs.cache-hit != 'true' run: | opam install -y dune opam install -y . --deps-only --with-doc --with-test --locked --unlock-base From df2ce1609bec1931bf6f8a72b2d4338155e4c1ee Mon Sep 17 00:00:00 2001 From: aronerben Date: Tue, 16 Aug 2022 09:29:42 +0200 Subject: [PATCH 4/4] Update CI setup --- .github/workflows/ci.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed404ec..e1068e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,14 +31,10 @@ jobs: restore-keys: | v2-${{ runner.os }}-opam-${{ matrix.ocaml-version }}- - name: Use OCaml ${{ matrix.ocaml-version }} - uses: avsm/setup-ocaml@v1 + uses: ocaml/setup-ocaml@v2 with: - ocaml-version: ${{ matrix.ocaml-version }} - - name: Install dependencies - run: | - opam install -y dune - opam install -y . --deps-only --with-doc --with-test --locked --unlock-base - opam install -y alcotest + ocaml-compiler: ${{ matrix.ocaml-compiler }} + dune-cache: true - name: Recover from an Opam broken state if: steps.cache-opam.outputs.cache-hit == 'true' run: opam upgrade --fixup