Skip to content

Commit

Permalink
fix(GoogleCloudPlatform#189): Refactor test case and add a case where…
Browse files Browse the repository at this point in the history
… repo name is not set
  • Loading branch information
VuKrampHub committed Apr 3, 2024
1 parent 316728c commit 4dbb911
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions githubissues/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,31 @@ func TestConfigs(t *testing.T) {
}

func TestGetGithubRepo(t *testing.T) {
// test GetGithubRepo method
build := &cbpb.Build{
Substitutions: map[string]string{"REPO_FULL_NAME": "somename/somerepo"},
}
if got, want := GetGithubRepo(build), "somename/somerepo"; got != want {
t.Errorf("got %q, want %q", got, want)
for _, tc := range []struct {
name string
build *cbpb.Build
expected string
}{{
name: "REPO_FULL_NAME is set",
// test GetGithubRepo method
build: &cbpb.Build{
Substitutions: map[string]string{"REPO_FULL_NAME": "somename/somerepo"},
},
expected: "somename/somerepo",
}, {
name: "REPO_FULL_NAME is not set",
// test GetGithubRepo method
build: &cbpb.Build{
Substitutions: map[string]string{},
},
expected: "",
},
} {
t.Run(tc.name, func(t *testing.T) {
actual := GetGithubRepo(tc.build)
if actual != tc.expected {
t.Errorf("expected %q, got %q", tc.expected, actual)
}
})
}
}

0 comments on commit 4dbb911

Please sign in to comment.