github.com/billybanfield/evergreen@v0.0.0-20170525200750-eeee692790f7/model/project_ref_test.go (about)

     1  package model
     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  func TestFindOneProjectRef(t *testing.T) {
    12  	Convey("With an existing repository ref", t, func() {
    13  		testutil.HandleTestingErr(db.Clear(ProjectRefCollection), t,
    14  			"Error clearing collection")
    15  		projectRef := &ProjectRef{
    16  			Owner:      "mongodb",
    17  			Repo:       "mci",
    18  			Branch:     "master",
    19  			RepoKind:   "github",
    20  			Enabled:    true,
    21  			BatchTime:  10,
    22  			Identifier: "ident",
    23  		}
    24  		Convey("all fields should be returned accurately for the "+
    25  			"corresponding project ref", func() {
    26  			So(projectRef.Insert(), ShouldBeNil)
    27  			projectRefFromDB, err := FindOneProjectRef("ident")
    28  			So(err, ShouldBeNil)
    29  			So(projectRefFromDB, ShouldNotEqual, nil)
    30  			So(projectRefFromDB.Owner, ShouldEqual, "mongodb")
    31  			So(projectRefFromDB.Repo, ShouldEqual, "mci")
    32  			So(projectRefFromDB.Branch, ShouldEqual, "master")
    33  			So(projectRefFromDB.RepoKind, ShouldEqual, "github")
    34  			So(projectRefFromDB.Enabled, ShouldEqual, true)
    35  			So(projectRefFromDB.BatchTime, ShouldEqual, 10)
    36  			So(projectRefFromDB.Identifier, ShouldEqual, "ident")
    37  		})
    38  	})
    39  }