github.com/justinjmoses/evergreen@v0.0.0-20170530173719-1d50e381ff0d/thirdparty/git_test.go (about)

     1  package thirdparty
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/evergreen-ci/evergreen/db"
     7  	"github.com/evergreen-ci/evergreen/testutil"
     8  	. "github.com/smartystreets/goconvey/convey"
     9  )
    10  
    11  var testConfig = testutil.TestConfig()
    12  
    13  func init() {
    14  	db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(testConfig))
    15  }
    16  
    17  func TestGetGithubCommits(t *testing.T) {
    18  	testutil.ConfigureIntegrationTest(t, testConfig, "TestGetGithubCommits")
    19  	Convey("When requesting github commits with a valid OAuth token...", t, func() {
    20  		Convey("Fetching commits from the repository should not return any errors", func() {
    21  			commitsURL := "https://api.github.com/repos/deafgoat/mci-test/commits"
    22  			_, _, err := GetGithubCommits(testConfig.Credentials["github"], commitsURL)
    23  			So(err, ShouldBeNil)
    24  		})
    25  
    26  		Convey("Fetching commits from the repository should return all available commits", func() {
    27  			commitsURL := "https://api.github.com/repos/deafgoat/mci-test/commits"
    28  			githubCommits, _, err := GetGithubCommits(testConfig.Credentials["github"], commitsURL)
    29  			So(err, ShouldBeNil)
    30  			So(len(githubCommits), ShouldEqual, 3)
    31  		})
    32  	})
    33  }