github.com/billybanfield/evergreen@v0.0.0-20170525200750-eeee692790f7/model/test_log_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 TestTestLogInsertAndFind(t *testing.T) {
    12  	Convey("With a test log", t, func() {
    13  
    14  		testutil.HandleTestingErr(
    15  			db.Clear(TestLogCollection), t,
    16  			"error clearing test log collection")
    17  
    18  		log := &TestLog{
    19  			Name:          "TestNothing",
    20  			Task:          "TestTask1000",
    21  			TaskExecution: 5,
    22  			Lines: []string{
    23  				"did some stuff",
    24  				"did some other stuff",
    25  				"finished doing stuff",
    26  			},
    27  		}
    28  
    29  		Convey("inserting that test log into the db", func() {
    30  			err := log.Insert()
    31  			So(err, ShouldBeNil)
    32  
    33  			Convey("the test log should be findable in the db", func() {
    34  				logFromDB, err := FindOneTestLog("TestNothing", "TestTask1000", 5)
    35  				So(err, ShouldBeNil)
    36  				So(logFromDB, ShouldResemble, log)
    37  			})
    38  
    39  			Convey("but a nonexistant test log should not be found", func() {
    40  				logFromDB, err := FindOneTestLog("blech", "blah", 1)
    41  				So(logFromDB, ShouldBeNil)
    42  				So(err, ShouldBeNil)
    43  			})
    44  
    45  		})
    46  
    47  	})
    48  
    49  }