|
1 | 1 | #lang racket/base |
2 | 2 |
|
3 | | - |
4 | 3 | (require rackunit |
5 | 4 | resyntax/private/github) |
6 | 5 |
|
7 | 6 |
|
8 | 7 | (module+ test |
9 | 8 | (test-case "github-review-comment-jsexpr" |
10 | | - |
11 | 9 | (test-case "single-line comment" |
12 | 10 | (define comment |
13 | 11 | (github-review-comment |
|
24 | 22 | (check-equal? (hash-ref result 'side) "RIGHT") |
25 | 23 | (check-false (hash-has-key? result 'start_line)) |
26 | 24 | (check-false (hash-has-key? result 'start_side))) |
27 | | - |
28 | 25 | (test-case "multi-line comment" |
29 | 26 | (define comment |
30 | 27 | (github-review-comment |
|
41 | 38 | (check-equal? (hash-ref result 'line) 8) |
42 | 39 | (check-equal? (hash-ref result 'start_side) "LEFT") |
43 | 40 | (check-equal? (hash-ref result 'side) "RIGHT"))) |
44 | | - |
45 | 41 | (test-case "github-review-request-jsexpr" |
46 | 42 | (define comment1 |
47 | 43 | (github-review-comment |
|
73 | 69 | (check-equal? (hash-ref result 'body) "Review body") |
74 | 70 | (check-equal? (hash-ref result 'event) "COMMENT") |
75 | 71 | (check-equal? (length (hash-ref result 'comments)) 2)) |
76 | | - |
77 | 72 | (test-case "git-ref->pr-number" |
78 | | - |
79 | 73 | (test-case "valid PR ref" |
80 | 74 | (check-equal? (git-ref->pr-number "refs/pull/42/merge") 42) |
81 | 75 | (check-equal? (git-ref->pr-number "refs/pull/123/merge") 123) |
82 | 76 | (check-equal? (git-ref->pr-number "refs/pull/1/merge") 1)) |
83 | | - |
84 | 77 | (test-case "invalid refs raise errors" |
85 | 78 | (check-exn exn:fail? (lambda () (git-ref->pr-number "refs/heads/main"))) |
86 | 79 | (check-exn exn:fail? (lambda () (git-ref->pr-number "refs/pull/42/head"))) |
87 | 80 | (check-exn exn:fail? (lambda () (git-ref->pr-number "invalid"))))) |
88 | | - |
89 | 81 | (test-case "github-review-body" |
90 | | - |
91 | 82 | (test-case "with comments" |
92 | 83 | (check-equal? (github-review-body #t 1) |
93 | 84 | "[Resyntax](https://docs.racket-lang.org/resyntax/) analyzed 1 file in this pull request and has added suggestions.") |
94 | 85 | (check-equal? (github-review-body #t 5) |
95 | 86 | "[Resyntax](https://docs.racket-lang.org/resyntax/) analyzed 5 files in this pull request and has added suggestions.")) |
96 | | - |
97 | 87 | (test-case "without comments" |
98 | 88 | (check-equal? (github-review-body #f 1) |
99 | 89 | "[Resyntax](https://docs.racket-lang.org/resyntax/) analyzed 1 file in this pull request and found no issues.") |
|
0 commit comments