2019-07-27 16:24:13 +02:00
|
|
|
module ParseTest exposing
|
|
|
|
( invalidHostInUrlBitbucket
|
|
|
|
, invalidHostInUrlGitHub
|
2019-07-28 17:32:50 +02:00
|
|
|
, invalidHostInUrlGitLab
|
2019-07-27 16:24:13 +02:00
|
|
|
, invalidUrlBitbucket
|
|
|
|
, invalidUrlGitHub
|
2019-07-28 17:32:50 +02:00
|
|
|
, invalidUrlGitLab
|
2019-07-27 16:24:13 +02:00
|
|
|
, validHttpUrlBitbucket
|
|
|
|
, validHttpUrlGitHub
|
2019-07-28 17:32:50 +02:00
|
|
|
, validHttpUrlGitLab
|
2019-07-27 16:24:13 +02:00
|
|
|
, validHttpsUrlBitbucket
|
|
|
|
, validHttpsUrlGitHub
|
2019-07-28 17:32:50 +02:00
|
|
|
, validHttpsUrlGitLab
|
2019-07-27 16:24:13 +02:00
|
|
|
, validUrlWithoutProtocolBitbucket
|
|
|
|
, validUrlWithoutProtocolGitHub
|
2019-07-28 17:32:50 +02:00
|
|
|
, validUrlWithoutProtocolGitLab
|
2019-07-27 16:24:13 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
import Data exposing (Provider(..), Url)
|
|
|
|
import Expect
|
|
|
|
import Parse exposing (parseUrl)
|
|
|
|
import Test exposing (Test, test)
|
|
|
|
|
|
|
|
|
|
|
|
expectedUrl : Provider -> Url
|
|
|
|
expectedUrl prov =
|
|
|
|
{ prov = prov, user = "user", repo = "repo", gitref = "master", file = "README.md" }
|
|
|
|
|
|
|
|
|
|
|
|
expectedGitHubUrl : Url
|
|
|
|
expectedGitHubUrl =
|
|
|
|
expectedUrl GitHub
|
|
|
|
|
|
|
|
|
|
|
|
expectedBitbucketUrl : Url
|
|
|
|
expectedBitbucketUrl =
|
|
|
|
expectedUrl Bitbucket
|
|
|
|
|
|
|
|
|
2019-07-28 17:32:50 +02:00
|
|
|
expectedGitLabUrl : Url
|
|
|
|
expectedGitLabUrl =
|
|
|
|
expectedUrl GitLab
|
|
|
|
|
|
|
|
|
2019-07-27 16:24:13 +02:00
|
|
|
validHttpsUrlGitHub : Test
|
|
|
|
validHttpsUrlGitHub =
|
|
|
|
test "Parsing Valid HTTPS URL for GitHub"
|
|
|
|
(\_ -> Expect.equal (Just expectedGitHubUrl) (parseUrl "https://GiThUb.CoM/user/repo/blob/master/README.md"))
|
|
|
|
|
|
|
|
|
|
|
|
validHttpUrlGitHub : Test
|
|
|
|
validHttpUrlGitHub =
|
|
|
|
test "Parsing Valid HTTP URL for GitHub"
|
|
|
|
(\_ -> Expect.equal (Just expectedGitHubUrl) (parseUrl "http://GiThUb.CoM/user/repo/blob/master/README.md"))
|
|
|
|
|
|
|
|
|
|
|
|
validUrlWithoutProtocolGitHub : Test
|
|
|
|
validUrlWithoutProtocolGitHub =
|
|
|
|
test "Parsing Valid URL without Protocol for GitHub"
|
|
|
|
(\_ -> Expect.equal (Just expectedGitHubUrl) (parseUrl "GiThUb.CoM/user/repo/blob/master/README.md"))
|
|
|
|
|
|
|
|
|
|
|
|
invalidUrlGitHub : Test
|
|
|
|
invalidUrlGitHub =
|
|
|
|
test "Parsing Invalid URL for GitHub"
|
|
|
|
(\_ -> Expect.equal Nothing (parseUrl "https://GiThUb.CoM/user"))
|
|
|
|
|
|
|
|
|
|
|
|
invalidHostInUrlGitHub : Test
|
|
|
|
invalidHostInUrlGitHub =
|
|
|
|
test "Parsing Invalid Host in URL for GitHub"
|
|
|
|
(\_ -> Expect.equal Nothing (parseUrl "https://example.com/user/repo/blob/master/README.md"))
|
|
|
|
|
|
|
|
|
|
|
|
validHttpsUrlBitbucket : Test
|
|
|
|
validHttpsUrlBitbucket =
|
|
|
|
test "Parsing Valid HTTPS URL for Bitbucket"
|
|
|
|
(\_ -> Expect.equal (Just expectedBitbucketUrl) (parseUrl "https://bItBuCkEt.OrG/user/repo/src/master/README.md"))
|
|
|
|
|
|
|
|
|
|
|
|
validHttpUrlBitbucket : Test
|
|
|
|
validHttpUrlBitbucket =
|
|
|
|
test "Parsing Valid HTTP URL for Bitbucket"
|
|
|
|
(\_ -> Expect.equal (Just expectedBitbucketUrl) (parseUrl "http://BiTbUcKeT.oRg/user/repo/src/master/README.md"))
|
|
|
|
|
|
|
|
|
|
|
|
validUrlWithoutProtocolBitbucket : Test
|
|
|
|
validUrlWithoutProtocolBitbucket =
|
|
|
|
test "Parsing Valid URL without Protocol for Bitbucket"
|
|
|
|
(\_ -> Expect.equal (Just expectedBitbucketUrl) (parseUrl "bitbucket.org/user/repo/src/master/README.md"))
|
|
|
|
|
|
|
|
|
|
|
|
invalidUrlBitbucket : Test
|
|
|
|
invalidUrlBitbucket =
|
|
|
|
test "Parsing Invalid URL for Bitbucket"
|
|
|
|
(\_ -> Expect.equal Nothing (parseUrl "https://bitBucket.ORG/user"))
|
|
|
|
|
|
|
|
|
|
|
|
invalidHostInUrlBitbucket : Test
|
|
|
|
invalidHostInUrlBitbucket =
|
|
|
|
test "Parsing Invalid Host in URL for Bitbucket"
|
|
|
|
(\_ -> Expect.equal Nothing (parseUrl "https://example.com/user/repo/blob/src/README.md"))
|
2019-07-28 17:32:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
validHttpsUrlGitLab : Test
|
|
|
|
validHttpsUrlGitLab =
|
|
|
|
test "Parsing Valid HTTPS URL for GitLab"
|
|
|
|
(\_ -> Expect.equal (Just expectedGitLabUrl) (parseUrl "https://GITLAB.CoM/user/repo/blob/master/README.md"))
|
|
|
|
|
|
|
|
|
|
|
|
validHttpUrlGitLab : Test
|
|
|
|
validHttpUrlGitLab =
|
|
|
|
test "Parsing Valid HTTP URL for GitLab"
|
|
|
|
(\_ -> Expect.equal (Just expectedGitLabUrl) (parseUrl "http://gItLaB.CoM/user/repo/blob/master/README.md"))
|
|
|
|
|
|
|
|
|
|
|
|
validUrlWithoutProtocolGitLab : Test
|
|
|
|
validUrlWithoutProtocolGitLab =
|
|
|
|
test "Parsing Valid URL without Protocol for GitLab"
|
|
|
|
(\_ -> Expect.equal (Just expectedGitLabUrl) (parseUrl "GiTlAb.CoM/user/repo/blob/master/README.md"))
|
|
|
|
|
|
|
|
|
|
|
|
invalidUrlGitLab : Test
|
|
|
|
invalidUrlGitLab =
|
|
|
|
test "Parsing Invalid URL for GitLab"
|
|
|
|
(\_ -> Expect.equal Nothing (parseUrl "https://gitLab.CoM/user"))
|
|
|
|
|
|
|
|
|
|
|
|
invalidHostInUrlGitLab : Test
|
|
|
|
invalidHostInUrlGitLab =
|
|
|
|
test "Parsing Invalid Host in URL for GitLab"
|
|
|
|
(\_ -> Expect.equal Nothing (parseUrl "https://example.com/user/repo/blob/master/README.md"))
|