(t *testing.T)
| 91 | } |
| 92 | |
| 93 | func TestChecks_Success(t *testing.T) { |
| 94 | refTime := time.Now() |
| 95 | startedAt := refTime.Add(-time.Second * 30) |
| 96 | finishedAt := refTime.Add(-time.Second * 15) |
| 97 | |
| 98 | mockRepository := new(mocks.Repository) |
| 99 | mockRepository.On("GetChecks", AnythingOfType("string"), AnythingOfType("string"), AnythingOfType("string")). |
| 100 | Return(&models.Checks{ |
| 101 | Runs: []models.Run{ |
| 102 | { |
| 103 | ID: 10, |
| 104 | Status: "completed", |
| 105 | Conclusion: "success", |
| 106 | StartedAt: ToTime(startedAt), |
| 107 | CompletedAt: ToTime(finishedAt), |
| 108 | }, |
| 109 | }, |
| 110 | }, nil) |
| 111 | |
| 112 | gu := NewGithubUsecase(mockRepository) |
| 113 | |
| 114 | expected := coreModels.NewTile(api.GithubChecksTileType).WithBuild() |
| 115 | expected.Label = "test" |
| 116 | expected.Build.Branch = ToString("master") |
| 117 | |
| 118 | expected.Status = coreModels.SuccessStatus |
| 119 | expected.Build.PreviousStatus = coreModels.UnknownStatus |
| 120 | expected.Build.StartedAt = ToTime(startedAt) |
| 121 | expected.Build.FinishedAt = ToTime(finishedAt) |
| 122 | |
| 123 | tile, err := gu.Checks(&models.ChecksParams{Owner: "test", Repository: "test", Ref: "master"}) |
| 124 | if assert.NoError(t, err) { |
| 125 | assert.NotNil(t, tile) |
| 126 | assert.Equal(t, expected, tile) |
| 127 | |
| 128 | mockRepository.AssertNumberOfCalls(t, "GetChecks", 1) |
| 129 | mockRepository.AssertExpectations(t) |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | func TestChecks_Failure(t *testing.T) { |
| 134 | refTime := time.Now() |
nothing calls this directly
no test coverage detected