Skip to content

Commit

Permalink
Merge pull request #99 from guibou/fix_url_and_test
Browse files Browse the repository at this point in the history
Fix url and test
  • Loading branch information
guibou authored Apr 24, 2024
2 parents 6e83e1b + 50fd3d0 commit 789a815
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
30 changes: 24 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions krank.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ test-suite krank-test
Utils.Req
build-depends: hspec >= 2.7
, hspec-expectations
, hspec-discover
ghc-options: -threaded -rtsopts -with-rtsopts=-N

executable krank
Expand Down
2 changes: 1 addition & 1 deletion src/Krank/Checkers/IssueTracker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ serverDomain (Gitlab (GitlabHost h)) = h
gitRepoRe :: RE.Regex
-- NOTE: \b at the beginning is really import for performances
-- because it dramatically reduces the number of backtracks
gitRepoRe = [RE.re|\b(?>https?://)?(?>www\.)?([^/ ]+)/([^ ]+)/([^- ][^/ ]*)(?>/-)?/issues/([0-9]+)|]
gitRepoRe = [RE.re|\b(?>https?://)?(?>www\.)?([^/ ]+)/([^ /][^ ]*)/([^-/ ][^/ ]*)(?>/-)?/issues/([0-9]+)|]

-- | Extract all issues on one line and returns a list of the raw text associated with an issue
extractIssuesOnALine :: ByteString -> [(Int, GitIssueRef)]
Expand Down
5 changes: 4 additions & 1 deletion tests/Test/Krank/Checkers/IssueTrackerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,16 @@ giturlTests domain = do
it "handles long gitlab url with groups and with the odd /-" $ do
let match = check [fmt|{domainName}/gbataille_main/sub_level_1/sub_level_2/deep_in_groups/-/issues/12|]
match `shouldBe` Just (GitIssueRef domain "gbataille_main/sub_level_1/sub_level_2" "deep_in_groups" 12)
it "handle an url embeded in markdown" $ do
let match = check [fmt|lalalalalalaalla [Issue XX](https://{domainName}/foo/bar/issues/123) blo blo blu|]
match `shouldBe` Just (GitIssueRef domain "foo" "bar" 123)

spec :: Spec
spec = do
context "Test.Krank.Checkers.specIssueTracker" $ do
describe "#githubParser" $
giturlTests Github
describe "#githlabParser" $
describe "#gitlabParser" $
giturlTests (Gitlab (GitlabHost "gitlab.com"))
describe "#extractIssues" $
it "handles both github and gitlab" $
Expand Down
4 changes: 3 additions & 1 deletion tests/Test/Utils/GithubSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ spec = do
showGithubException exception `shouldBe` showHTTPException showRawResponse exception

dummyResponse :: Status -> Response ()
#if MIN_VERSION_http_client(0,7,8)
#if MIN_VERSION_http_client(0,7,16)
dummyResponse status = Response status http11 [] () (createCookieJar []) (ResponseClose $ pure ()) (error "WTF") []
#elif MIN_VERSION_http_client(0,7,8)
dummyResponse status = Response status http11 [] () (createCookieJar []) (ResponseClose $ pure ()) (error "WTF")
#else
dummyResponse status = Response status http11 [] () (createCookieJar []) (ResponseClose $ pure ())
Expand Down
4 changes: 3 additions & 1 deletion tests/Test/Utils/GitlabSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ spec = do
showGitlabException exception `shouldBe` showHTTPException showRawResponse exception

dummyResponse :: Status -> Response ()
#if MIN_VERSION_http_client(0,7,8)
#if MIN_VERSION_http_client(0,7,16)
dummyResponse status = Response status http11 [] () (createCookieJar []) (ResponseClose $ pure ()) (error "WTF") []
#elif MIN_VERSION_http_client(0,7,8)
dummyResponse status = Response status http11 [] () (createCookieJar []) (ResponseClose $ pure ()) (error "WTF")
#else
dummyResponse status = Response status http11 [] () (createCookieJar []) (ResponseClose $ pure ())
Expand Down

0 comments on commit 789a815

Please sign in to comment.