diff --git a/github/data_source_github_release.go b/github/data_source_github_release.go index 7e8ab28050..5f3cfb5575 100644 --- a/github/data_source_github_release.go +++ b/github/data_source_github_release.go @@ -112,7 +112,7 @@ func dataSourceGithubReleaseRead(d *schema.ResourceData, meta interface{}) error return errors.New("'release_id' must be set when 'retrieve_by' = 'id'") } - log.Printf("[INFO] Refreshing GitHub release by id %s from repository %s", releaseID, repository) + log.Printf("[INFO] Refreshing GitHub release by id %d from repository %s", releaseID, repository) release, _, err = client.Repositories.GetRelease(ctx, owner, repository, releaseID) case "tag": tag := d.Get("release_tag").(string) diff --git a/github/data_source_github_release_test.go b/github/data_source_github_release_test.go new file mode 100644 index 0000000000..70b1985afa --- /dev/null +++ b/github/data_source_github_release_test.go @@ -0,0 +1,61 @@ +package github + +import ( + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccGithubReleaseDataSource_fetchByLatestNoReleaseReturnsError(t *testing.T) { + repo := "nonExistantRepo" + owner := "no-user" + retrieveBy := "latest" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckGithubReleaseDataSourceConfig(repo, owner, retrieveBy), + ExpectError: regexp.MustCompile(`Not Found`), + }, + }, + }) +} + +// func TestAccGithubReleaseDataSource_latestExisting(t *testing.T) { + +// } + +// func TestAccGithubReleaseDataSource_fetchByIdWithNoIdReturnsError(t *testing.T) { + +// } + +// func TestAccGithubReleaseDataSource_fetchByIdExisting(t *testing.T) { + +// } + +// func TestAccGithubReleaseDataSource_fetchByTagNoTagReturnsError(t *testing.T) { + +// } + +// func TestAccGithubReleaseDataSource_fetchByTagExisting(t *testing.T) { + +// } + +// func TestAccGithubReleaseDataSource_invalidRetrieveMethodReturnsError(t *testing.T) { + +// } + +func testAccCheckGithubReleaseDataSourceConfig(repo string, owner string, retrieveBy string) string { + return fmt.Sprintf(` +data "github_release" "test" { + repository = "%s" + owner = "%s" + retrieve_by = "%s" +} +`, repo, owner, retrieveBy) +}