(t *testing.T)
| 131 | } |
| 132 | |
| 133 | func TestChecks_Failure(t *testing.T) { |
| 134 | refTime := time.Now() |
| 135 | |
| 136 | mockRepository := new(mocks.Repository) |
| 137 | mockRepository.On("GetChecks", AnythingOfType("string"), AnythingOfType("string"), AnythingOfType("string")). |
| 138 | Return(&models.Checks{ |
| 139 | HeadCommit: ToString("sha"), |
| 140 | Runs: []models.Run{ |
| 141 | { |
| 142 | ID: 10, |
| 143 | Status: "completed", |
| 144 | Conclusion: "failure", |
| 145 | StartedAt: ToTime(refTime.Add(-time.Second * 30)), |
| 146 | CompletedAt: ToTime(refTime.Add(-time.Second * 15)), |
| 147 | }, |
| 148 | }, |
| 149 | }, nil) |
| 150 | mockRepository.On("GetCommit", AnythingOfType("string"), AnythingOfType("string"), AnythingOfType("string")). |
| 151 | Return(&models.Commit{ |
| 152 | Author: coreModels.Author{ |
| 153 | Name: "test", |
| 154 | AvatarURL: "https://test.example.com", |
| 155 | }, |
| 156 | }, nil) |
| 157 | |
| 158 | gu := NewGithubUsecase(mockRepository) |
| 159 | |
| 160 | expected := coreModels.NewTile(api.GithubChecksTileType).WithBuild() |
| 161 | expected.Label = "test" |
| 162 | expected.Build.Branch = ToString("master") |
| 163 | |
| 164 | expected.Status = coreModels.FailedStatus |
| 165 | expected.Build.PreviousStatus = coreModels.UnknownStatus |
| 166 | expected.Build.StartedAt = ToTime(refTime.Add(-time.Second * 30)) |
| 167 | expected.Build.FinishedAt = ToTime(refTime.Add(-time.Second * 15)) |
| 168 | expected.Build.Author = &coreModels.Author{ |
| 169 | Name: "test", |
| 170 | AvatarURL: "https://test.example.com", |
| 171 | } |
| 172 | |
| 173 | tile, err := gu.Checks(&models.ChecksParams{Owner: "test", Repository: "test", Ref: "master"}) |
| 174 | if assert.NoError(t, err) { |
| 175 | assert.NotNil(t, tile) |
| 176 | assert.Equal(t, expected, tile) |
| 177 | |
| 178 | mockRepository.AssertNumberOfCalls(t, "GetChecks", 1) |
| 179 | mockRepository.AssertNumberOfCalls(t, "GetCommit", 1) |
| 180 | mockRepository.AssertExpectations(t) |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | func TestChecks_Queued(t *testing.T) { |
| 185 | refTime := time.Now() |
nothing calls this directly
no test coverage detected