Skip to content

Commit

Permalink
Only use ppx_expect in tests (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetiot authored Mar 20, 2024
1 parent c79ce78 commit 512356f
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 102 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## unreleased

### Fixed

- `ppx_expect` is now only used in tests (#29, @gpetiot)

## 1.0.0

### Added
Expand Down
100 changes: 0 additions & 100 deletions lib/contributions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -205,103 +205,3 @@ let pp f { activity; _ } =
| repos -> Fmt.(list ~sep:(cut ++ cut)) pp_repo f repos

let pp fs t = Fmt.pf fs "@[<v>%a@]" pp t

let%expect_test "Contributions.pp" =
let contributions_example = { username = "me"; activity = Repo_map.empty } in
Format.printf "%a" pp contributions_example;
[%expect {|
(no activity) |}]

let contributions_example =
{
username = "me";
activity =
Repo_map.empty
|> Repo_map.add "gpetiot/js_of_ocaml"
[
{
repo = "gpetiot/js_of_ocaml";
kind = `New_repo;
date = "2024-03-01T10:43:33Z";
url = "https://github.com/gpetiot/js_of_ocaml";
title = "Title1";
body = "";
};
]
|> Repo_map.add "realworldocaml/mdx"
[
{
repo = "realworldocaml/mdx";
kind = `Review "APPROVED";
date = "2024-03-05T11:43:04Z";
url =
"https://github.com/realworldocaml/mdx/pull/449#pullrequestreview-1916654244";
title = "Title2";
body = "xxx";
};
{
repo = "realworldocaml/mdx";
kind = `PR;
date = "2024-03-04T17:20:11Z";
url = "https://github.com/realworldocaml/mdx/pull/450";
title = "Title3";
body = "xxx";
};
]
|> Repo_map.add "tarides/okra"
[
{
repo = "tarides/okra";
kind = `Review "APPROVED";
date = "2024-02-28T11:09:41Z";
url =
"https://github.com/tarides/okra/pull/166#pullrequestreview-1905972361";
title = "Title4";
body = "xxx";
};
{
repo = "tarides/okra";
kind = `Issue;
date = "2024-02-27T12:05:04Z";
url = "https://github.com/tarides/okra/issues/165";
title = "Title5";
body = "xxx";
};
{
repo = "tarides/okra";
kind = `Issue_comment;
date = "2024-03-13T11:09:56Z";
url =
"https://github.com/tarides/okra/issues/114#issuecomment-1994130584";
title = "Title6";
body = "xxx";
};
];
}

let%expect_test "Contributions.pp" =
Format.printf "%a" pp contributions_example;
[%expect
{|
### gpetiot/js_of_ocaml

Created repository [gpetiot/js_of_ocaml](https://github.com/gpetiot/js_of_ocaml).

### realworldocaml/mdx

APPROVED Title2 [#449](https://github.com/realworldocaml/mdx/pull/449#pullrequestreview-1916654244).
xxx

Title3 [#450](https://github.com/realworldocaml/mdx/pull/450).
xxx

### tarides/okra

APPROVED Title4 [#166](https://github.com/tarides/okra/pull/166#pullrequestreview-1905972361).
xxx

Title5 [#165](https://github.com/tarides/okra/issues/165).
xxx

Commented on "Title6" [#114](https://github.com/tarides/okra/issues/114#issuecomment-1994130584).
xxx |}]
3 changes: 1 addition & 2 deletions lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
(name get_activity)
(public_name get-activity-lib)
(libraries astring curly fmt yojson)
(inline_tests)
(preprocess
(pps ppx_expect ppx_yojson_conv)))
(pps ppx_yojson_conv)))
6 changes: 6 additions & 0 deletions test/expect/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(library
(name expect)
(inline_tests)
(libraries get-activity-lib)
(preprocess
(pps ppx_expect)))
152 changes: 152 additions & 0 deletions test/expect/main.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
open Get_activity

let contributions_example ~user =
let open Contributions in
{
username = user;
activity =
Repo_map.empty
|> Repo_map.add "gpetiot/config.ml"
[
{
repo = "gpetiot/config.ml";
kind = `New_repo;
date = "2024-03-02T09:40:41Z";
url = "https://github.com/gpetiot/config.ml";
title = "Created new repository";
body = "";
};
]
|> Repo_map.add "gpetiot/js_of_ocaml"
[
{
repo = "gpetiot/js_of_ocaml";
kind = `New_repo;
date = "2024-03-01T10:43:33Z";
url = "https://github.com/gpetiot/js_of_ocaml";
title = "Created new repository";
body = "";
};
]
|> Repo_map.add "ocaml-ppx/ocamlformat"
[
{
repo = "ocaml-ppx/ocamlformat";
kind = `PR;
date = "2024-03-05T11:21:22Z";
url = "https://github.com/ocaml-ppx/ocamlformat/pull/2533";
title = "Represent the expr sequence as a list";
body = "xxx";
};
]
|> Repo_map.add "realworldocaml/mdx"
[
{
repo = "realworldocaml/mdx";
kind = `Review "APPROVED";
date = "2024-03-05T11:43:04Z";
url =
"https://github.com/realworldocaml/mdx/pull/449#pullrequestreview-1916654244";
title = "Add upgrade instructions in the changelog for #446";
body = "xxx";
};
{
repo = "realworldocaml/mdx";
kind = `PR;
date = "2024-03-04T17:20:11Z";
url = "https://github.com/realworldocaml/mdx/pull/450";
title = "Add an 'exec' label to execute include OCaml blocks";
body = "xxx";
};
]
|> Repo_map.add "tarides/get-activity"
[
{
repo = "tarides/get-activity";
kind = `Issue;
date = "2024-03-04T11:55:37Z";
url = "https://github.com/tarides/get-activity/issues/8";
title =
"Add the PR/issues comments to the result of okra generate";
body = "xxx";
};
]
|> Repo_map.add "tarides/okra"
[
{
repo = "tarides/okra";
kind = `Review "APPROVED";
date = "2024-02-28T11:09:41Z";
url =
"https://github.com/tarides/okra/pull/166#pullrequestreview-1905972361";
title = "Make README.md more precise";
body = "xxx";
};
{
repo = "tarides/okra";
kind = `Issue_comment;
date = "2024-03-13T11:09:56Z";
url =
"https://github.com/tarides/okra/issues/114#issuecomment-1994130584";
title = "Gitlab: exception when parsing Gitlab's JSON";
body = "xxx";
};
{
repo = "tarides/okra";
kind = `Issue;
date = "2024-02-27T12:05:04Z";
url = "https://github.com/tarides/okra/issues/165";
title = "Make the `get-activity` package known to ocaml-ci";
body = "xxx";
};
];
}

let%expect_test "Contributions.pp" =
let open Contributions in
let contributions_example = { username = "me"; activity = Repo_map.empty } in
Format.printf "%a" pp contributions_example;
[%expect {|
(no activity) |}]

let%expect_test "Contributions.pp" =
let open Contributions in
Format.printf "%a" pp (contributions_example ~user:"me");
[%expect
{|
### gpetiot/config.ml

Created repository [gpetiot/config.ml](https://github.com/gpetiot/config.ml).

### gpetiot/js_of_ocaml

Created repository [gpetiot/js_of_ocaml](https://github.com/gpetiot/js_of_ocaml).

### ocaml-ppx/ocamlformat

Represent the expr sequence as a list [#2533](https://github.com/ocaml-ppx/ocamlformat/pull/2533).
xxx

### realworldocaml/mdx

APPROVED Add upgrade instructions in the changelog for #446 [#449](https://github.com/realworldocaml/mdx/pull/449#pullrequestreview-1916654244).
xxx

Add an 'exec' label to execute include OCaml blocks [#450](https://github.com/realworldocaml/mdx/pull/450).
xxx

### tarides/get-activity

Add the PR/issues comments to the result of okra generate [#8](https://github.com/tarides/get-activity/issues/8).
xxx

### tarides/okra

APPROVED Make README.md more precise [#166](https://github.com/tarides/okra/pull/166#pullrequestreview-1905972361).
xxx

Commented on "Gitlab: exception when parsing Gitlab's JSON" [#114](https://github.com/tarides/okra/issues/114#issuecomment-1994130584).
xxx

Make the `get-activity` package known to ocaml-ci [#165](https://github.com/tarides/okra/issues/165).
xxx |}]

0 comments on commit 512356f

Please sign in to comment.