MCPcopy Create free account
hub / github.com/monitoror/monitoror / TestChecks_Success

Function TestChecks_Success

monitorables/github/api/usecase/github_test.go:93–131  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func 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
133func TestChecks_Failure(t *testing.T) {
134 refTime := time.Now()

Callers

nothing calls this directly

Calls 4

WithBuildMethod · 0.80
NewGithubUsecaseFunction · 0.70
ChecksMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected