Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use ppx_expect in tests #29

Merged
merged 3 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (#<PR_NUMBER>, @gpetiot)
gpetiot marked this conversation as resolved.
Show resolved Hide resolved

## 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 |}]
Loading