Skip to content

Commit

Permalink
test: Added Test for Get/list branches github (#9140)
Browse files Browse the repository at this point in the history
Signed-off-by: rishabh625 <rishabhmishra625@gmail.com>
  • Loading branch information
rishabh625 authored Apr 19, 2022
1 parent 7594cad commit c7ff388
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions applicationset/services/scm_provider/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ func TestGithubListRepos(t *testing.T) {
}{
{
name: "blank protocol",
url: "git@github.com:argoproj/applicationset.git",
url: "git@github.com:argoproj/argo-cd.git",
branches: []string{"master"},
},
{
name: "ssh protocol",
proto: "ssh",
url: "git@github.com:argoproj/applicationset.git",
url: "git@github.com:argoproj/argo-cd.git",
},
{
name: "https protocol",
proto: "https",
url: "https://github.com/argoproj/applicationset.git",
url: "https://github.com/argoproj/argo-cd.git",
},
{
name: "other protocol",
Expand All @@ -65,8 +65,8 @@ func TestGithubListRepos(t *testing.T) {
{
name: "all branches",
allBranches: true,
url: "git@github.com:argoproj/applicationset.git",
branches: []string{"master", "release-0.1.0"},
url: "git@github.com:argoproj/argo-cd.git",
branches: []string{"master", "release-0.11"},
},
}

Expand All @@ -83,7 +83,7 @@ func TestGithubListRepos(t *testing.T) {
repos := []*Repository{}
branches := []string{}
for _, r := range rawRepos {
if r.Repository == "applicationset" {
if r.Repository == "argo-cd" {
repos = append(repos, r)
branches = append(branches, r.Branch)
}
Expand All @@ -102,7 +102,7 @@ func TestGithubHasPath(t *testing.T) {
host, _ := NewGithubProvider(context.Background(), "argoproj", "", "", false)
repo := &Repository{
Organization: "argoproj",
Repository: "applicationset",
Repository: "argo-cd",
Branch: "master",
}
ok, err := host.RepoHasPath(context.Background(), repo, "pkg/")
Expand All @@ -115,3 +115,19 @@ func TestGithubHasPath(t *testing.T) {
assert.Nil(t, err)
assert.False(t, ok)
}

func TestGithubGetBranches(t *testing.T) {
host, _ := NewGithubProvider(context.Background(), "argoproj", "", "", false)
repo := &Repository{
Organization: "argoproj",
Repository: "argo-cd",
Branch: "master",
}
repos, err := host.GetBranches(context.Background(), repo)
if err != nil {
checkRateLimit(t, err)
assert.NoError(t, err)
} else {
assert.Equal(t, repos[0].Branch, "master")
}
}

0 comments on commit c7ff388

Please sign in to comment.