Skip to content

Commit

Permalink
integrationsGH-144 - Adding initial testing
Browse files Browse the repository at this point in the history
  • Loading branch information
benj-fletch authored and Jeremy Udit committed Feb 18, 2020
1 parent 72ec46c commit f7896de
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion github/data_source_github_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
61 changes: 61 additions & 0 deletions github/data_source_github_release_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit f7896de

Please sign in to comment.