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

Fix url and test #99

Merged
merged 3 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading