github.com/billybanfield/evergreen@v0.0.0-20170525200750-eeee692790f7/apiv3/model/test_test.go (about) 1 package model 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/evergreen-ci/evergreen/model/task" 8 "github.com/evergreen-ci/evergreen/util" 9 . "github.com/smartystreets/goconvey/convey" 10 ) 11 12 type testCompare struct { 13 at APITest 14 st task.TestResult 15 } 16 17 func TestTestBuildFromService(t *testing.T) { 18 Convey("With a list of models to compare", t, func() { 19 sTime := time.Unix(12345, 6789) 20 eTime := time.Unix(9876, 54321) 21 modelPairs := []testCompare{ 22 23 { 24 at: APITest{ 25 Status: APIString("testStatus"), 26 TestFile: APIString("testFile"), 27 Logs: TestLogs{ 28 URL: APIString("testUrl"), 29 LineNum: 15, 30 URLRaw: APIString("testUrlRaw"), 31 LogId: "", 32 }, 33 ExitCode: 1, 34 StartTime: APITime(sTime), 35 EndTime: APITime(eTime), 36 }, 37 st: task.TestResult{ 38 Status: "testStatus", 39 TestFile: "testFile", 40 URL: "testUrl", 41 URLRaw: "testUrlRaw", 42 LineNum: 15, 43 LogId: "", 44 ExitCode: 1, 45 StartTime: util.ToPythonTime(sTime), 46 EndTime: util.ToPythonTime(eTime), 47 }, 48 }, 49 { 50 at: APITest{ 51 StartTime: APITime(time.Unix(0, 0)), 52 EndTime: APITime(time.Unix(0, 0)), 53 }, 54 st: task.TestResult{}, 55 }, 56 } 57 58 Convey("running BuildFromService(), should produce the equivalent model", func() { 59 for _, tc := range modelPairs { 60 apiTest := &APITest{} 61 err := apiTest.BuildFromService(&tc.st) 62 So(err, ShouldBeNil) 63 So(apiTest, ShouldResemble, &tc.at) 64 } 65 }) 66 }) 67 }