Skip to content

Commit

Permalink
Opam improvements (#44)
Browse files Browse the repository at this point in the history
* Add odoc dependency

* Add GitHub pages documentation

* Skip the tests if environment variables are not set

* Add documentation badge
  • Loading branch information
brendanlong authored May 7, 2020
1 parent bb7fe3c commit 589f1e2
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 35 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![CircleCI](https://circleci.com/gh/arenadotio/ocaml-mssql.svg?style=shield)](https://circleci.com/gh/arenadotio/ocaml-mssql)
[![Coverage Status](https://coveralls.io/repos/github/arenadotio/ocaml-mssql/badge.svg?branch=master)](https://coveralls.io/github/arenadotio/ocaml-mssql?branch=master)
[![Documentation](https://img.shields.io/badge/documentation-odoc-blue)](https://arenadotio.github.io/ocaml-mssql/mssql/index.html)

**Mssql** is an [Async](https://github.com/janestreet/async) OCaml SQL Server
library, currently using [FreeTDS](https://github.com/kennknowles/ocaml-freetds).
Expand Down
3 changes: 3 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

(authors "Arena Developers <silver-snakes@arena.io>")

(documentation "https://arenadotio.github.io/ocaml-mssql")

(source
(github arenadotio/ocaml-mssql))

Expand All @@ -36,6 +38,7 @@
(>= 1.2))
(ocaml
(>= 4.06.1))
(odoc :with-doc)
logs
(text
(>= 0.8.0))
Expand Down
2 changes: 2 additions & 0 deletions mssql.opam
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ maintainer: ["Arena Developers <silver-snakes@arena.io>"]
authors: ["Arena Developers <silver-snakes@arena.io>"]
license: "Apache-2.0"
homepage: "https://github.com/arenadotio/ocaml-mssql"
doc: "https://arenadotio.github.io/ocaml-mssql"
bug-reports: "https://github.com/arenadotio/ocaml-mssql/issues"
depends: [
"alcotest" {with-test & >= "1.0.1"}
Expand All @@ -16,6 +17,7 @@ depends: [
"ppx_jane"
"iter" {>= "1.2"}
"ocaml" {>= "4.06.1"}
"odoc" {with-doc}
"logs"
"text" {>= "0.8.0"}
"freetds" {>= "0.7"}
Expand Down
87 changes: 52 additions & 35 deletions test/test_mssql.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ open Async_kernel
open Async_unix
module Row = Mssql.Row

exception Environment_variables_not_set

let () =
Caml.Printexc.register_printer (function
| Environment_variables_not_set ->
Some
"Environment_variables_not_set. The following environment variables must be \
set to run the Mssql tests: MSSQL_TEST_SERVER, MSSQL_TEST_DATABASE, \
MSSQL_TEST_USERNAME, MSSQL_TEST_PASSWORD. Optionally, you can also set \
MSSQL_TEST_PORT but it is not required."
| _ -> None)
;;

let params =
lazy
([ "MSSQL_TEST_SERVER"
Expand All @@ -15,7 +28,7 @@ let params =
|> function
| [ Some host; Some db; Some user; Some password; port ] ->
host, db, user, password, Option.map ~f:Int.of_string port
| _ -> failwith "MSSQL_TEST_* environment not set")
| _ -> raise Environment_variables_not_set)
;;

let with_test_conn f =
Expand Down Expand Up @@ -603,38 +616,42 @@ let test_execute_pipe_error () =
;;

let () =
Thread_safe.block_on_async_exn
@@ fun () ->
[ ( "all"
, [ "select and convert", test_select_and_convert
; "multiple queries in execute", test_multiple_queries_in_execute
; ( "multiple queries in execute_multi_result"
, test_multiple_queries_in_execute_multi_result )
; "test_not_result_queries_don't_count", test_not_result_queries_don't_count
; "test_empty_result_sets_still_count", test_empty_result_sets_still_count
; "execute_unit", test_execute_unit
; "execute_unit fail", test_execute_unit_fail
; "execute_single", test_execute_single
; "execute_single fail", test_execute_single_fail
; "test list order", test_order
; "test params", test_param_parsing
; "test param out of range", test_param_out_of_range
; "test execute many", test_execute_many
; "test concurrent queries", test_concurrent_queries
; "test rollback", test_rollback
; "test auto rollback", test_auto_rollback
; "test commit", test_commit
; "test auto commit", test_auto_commit
; "test other execute during transaction", test_other_execute_during_transaction
; "test prevent transaction deadlock", test_prevent_transaction_deadlock
; "test exception in callback", test_exception_thrown_in_callback
; "test exception with multiple results", test_exception_with_multiple_results
; "test execute_pipe", test_execute_pipe
; "test execute_pipe_error", test_execute_pipe_error
]
@ round_trip_tests
@ recoding_tests
|> List.map ~f:(fun (name, f) -> Alcotest_async.test_case name `Quick f) )
]
|> Alcotest_async.run "mssql"
try
Lazy.force params |> ignore;
Thread_safe.block_on_async_exn
@@ fun () ->
[ ( "all"
, [ "select and convert", test_select_and_convert
; "multiple queries in execute", test_multiple_queries_in_execute
; ( "multiple queries in execute_multi_result"
, test_multiple_queries_in_execute_multi_result )
; "test_not_result_queries_don't_count", test_not_result_queries_don't_count
; "test_empty_result_sets_still_count", test_empty_result_sets_still_count
; "execute_unit", test_execute_unit
; "execute_unit fail", test_execute_unit_fail
; "execute_single", test_execute_single
; "execute_single fail", test_execute_single_fail
; "test list order", test_order
; "test params", test_param_parsing
; "test param out of range", test_param_out_of_range
; "test execute many", test_execute_many
; "test concurrent queries", test_concurrent_queries
; "test rollback", test_rollback
; "test auto rollback", test_auto_rollback
; "test commit", test_commit
; "test auto commit", test_auto_commit
; "test other execute during transaction", test_other_execute_during_transaction
; "test prevent transaction deadlock", test_prevent_transaction_deadlock
; "test exception in callback", test_exception_thrown_in_callback
; "test exception with multiple results", test_exception_with_multiple_results
; "test execute_pipe", test_execute_pipe
; "test execute_pipe_error", test_execute_pipe_error
]
@ round_trip_tests
@ recoding_tests
|> List.map ~f:(fun (name, f) -> Alcotest_async.test_case name `Quick f) )
]
|> Alcotest_async.run "mssql"
with
| Environment_variables_not_set as e -> Caml.Printexc.to_string e |> Caml.print_endline
;;

0 comments on commit 589f1e2

Please sign in to comment.