Extend git tests (#90)

This commit is contained in:
johnybx
2023-11-13 16:26:12 +01:00
committed by GitHub
parent 1f28486ab2
commit deed861871

View File

@@ -27,6 +27,18 @@ func TestExtractGitInfo_Success(t *testing.T) {
Namespace: "namespace-1",
},
},
{
desc: "Project configured in SSH under a single folder without .git extension",
getProjectRemoteUrl: func() (string, error) {
return "git@custom-gitlab.com:namespace-1/project-name", nil
},
expected: GitProjectInfo{
RemoteUrl: "git@custom-gitlab.com:namespace-1/project-name",
BranchName: "feature/abc",
ProjectName: "project-name",
Namespace: "namespace-1",
},
},
{
desc: "Project configured in SSH under one nested folder",
getProjectRemoteUrl: func() (string, error) {
@@ -51,6 +63,54 @@ func TestExtractGitInfo_Success(t *testing.T) {
Namespace: "namespace-1/namespace-2/namespace-3",
},
},
{
desc: "Project configured in SSH:// under a single folder",
getProjectRemoteUrl: func() (string, error) {
return "ssh://custom-gitlab.com/namespace-1/project-name.git", nil
},
expected: GitProjectInfo{
RemoteUrl: "ssh://custom-gitlab.com/namespace-1/project-name.git",
BranchName: "feature/abc",
ProjectName: "project-name",
Namespace: "namespace-1",
},
},
{
desc: "Project configured in SSH:// under a single folder without .git extension",
getProjectRemoteUrl: func() (string, error) {
return "ssh://custom-gitlab.com/namespace-1/project-name", nil
},
expected: GitProjectInfo{
RemoteUrl: "ssh://custom-gitlab.com/namespace-1/project-name",
BranchName: "feature/abc",
ProjectName: "project-name",
Namespace: "namespace-1",
},
},
{
desc: "Project configured in SSH:// under two nested folders",
getProjectRemoteUrl: func() (string, error) {
return "ssh://custom-gitlab.com/namespace-1/namespace-2/namespace-3/project-name.git", nil
},
expected: GitProjectInfo{
RemoteUrl: "ssh://custom-gitlab.com/namespace-1/namespace-2/namespace-3/project-name.git",
BranchName: "feature/abc",
ProjectName: "project-name",
Namespace: "namespace-1/namespace-2/namespace-3",
},
},
{
desc: "Project configured in HTTP and under a single folder without .git extension",
getProjectRemoteUrl: func() (string, error) {
return "http://custom-gitlab.com/namespace-1/project-name", nil
},
expected: GitProjectInfo{
RemoteUrl: "http://custom-gitlab.com/namespace-1/project-name",
BranchName: "feature/abc",
ProjectName: "project-name",
Namespace: "namespace-1",
},
},
{
desc: "Project configured in HTTPS and under a single folder",
getProjectRemoteUrl: func() (string, error) {