fix(01-02): replace silent test setup returns with t.Fatalf at 6 sites
- TestUpdateEventAndGetUpdates: UpdateEvent error now fails test - TestUpdatesHandler: UpdateEvent error now fails test - TestConcurrentUpdateEvent goroutine: UpdateEvent error now fails test - TestDismissHandler_Success: UpdateEvent error now fails test - TestDismissHandler_SlashInImageName: UpdateEvent error now fails test - TestDismissHandler_ReappearsAfterNewWebhook: bare UpdateEvent call now checked All 6 silent-return sites replaced; test failures are always visible to CI
This commit is contained in:
@@ -34,9 +34,8 @@ func TestUpdateEventAndGetUpdates(t *testing.T) {
|
|||||||
Created: time.Now(),
|
Created: time.Now(),
|
||||||
Platform: "linux/amd64",
|
Platform: "linux/amd64",
|
||||||
}
|
}
|
||||||
err := diun.UpdateEvent(event)
|
if err := diun.UpdateEvent(event); err != nil {
|
||||||
if err != nil {
|
t.Fatalf("test setup: UpdateEvent failed: %v", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
got, err := diun.GetUpdates()
|
got, err := diun.GetUpdates()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -149,9 +148,8 @@ func TestWebhookHandler_BadRequest(t *testing.T) {
|
|||||||
func TestUpdatesHandler(t *testing.T) {
|
func TestUpdatesHandler(t *testing.T) {
|
||||||
diun.UpdatesReset()
|
diun.UpdatesReset()
|
||||||
event := diun.DiunEvent{Image: "busybox:latest"}
|
event := diun.DiunEvent{Image: "busybox:latest"}
|
||||||
err := diun.UpdateEvent(event)
|
if err := diun.UpdateEvent(event); err != nil {
|
||||||
if err != nil {
|
t.Fatalf("test setup: UpdateEvent failed: %v", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
req := httptest.NewRequest(http.MethodGet, "/api/updates", nil)
|
req := httptest.NewRequest(http.MethodGet, "/api/updates", nil)
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
@@ -225,9 +223,8 @@ func TestConcurrentUpdateEvent(t *testing.T) {
|
|||||||
for i := range n {
|
for i := range n {
|
||||||
go func(i int) {
|
go func(i int) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
err := diun.UpdateEvent(diun.DiunEvent{Image: fmt.Sprintf("image:%d", i)})
|
if err := diun.UpdateEvent(diun.DiunEvent{Image: fmt.Sprintf("image:%d", i)}); err != nil {
|
||||||
if err != nil {
|
t.Fatalf("test setup: UpdateEvent[%d] failed: %v", i, err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}(i)
|
}(i)
|
||||||
}
|
}
|
||||||
@@ -283,9 +280,8 @@ func TestMainHandlerIntegration(t *testing.T) {
|
|||||||
|
|
||||||
func TestDismissHandler_Success(t *testing.T) {
|
func TestDismissHandler_Success(t *testing.T) {
|
||||||
diun.UpdatesReset()
|
diun.UpdatesReset()
|
||||||
err := diun.UpdateEvent(diun.DiunEvent{Image: "nginx:latest"})
|
if err := diun.UpdateEvent(diun.DiunEvent{Image: "nginx:latest"}); err != nil {
|
||||||
if err != nil {
|
t.Fatalf("test setup: UpdateEvent failed: %v", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
req := httptest.NewRequest(http.MethodPatch, "/api/updates/nginx:latest", nil)
|
req := httptest.NewRequest(http.MethodPatch, "/api/updates/nginx:latest", nil)
|
||||||
@@ -325,9 +321,8 @@ func TestDismissHandler_EmptyImage(t *testing.T) {
|
|||||||
|
|
||||||
func TestDismissHandler_SlashInImageName(t *testing.T) {
|
func TestDismissHandler_SlashInImageName(t *testing.T) {
|
||||||
diun.UpdatesReset()
|
diun.UpdatesReset()
|
||||||
err := diun.UpdateEvent(diun.DiunEvent{Image: "ghcr.io/user/image:tag"})
|
if err := diun.UpdateEvent(diun.DiunEvent{Image: "ghcr.io/user/image:tag"}); err != nil {
|
||||||
if err != nil {
|
t.Fatalf("test setup: UpdateEvent failed: %v", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
req := httptest.NewRequest(http.MethodPatch, "/api/updates/ghcr.io/user/image:tag", nil)
|
req := httptest.NewRequest(http.MethodPatch, "/api/updates/ghcr.io/user/image:tag", nil)
|
||||||
@@ -347,7 +342,9 @@ func TestDismissHandler_SlashInImageName(t *testing.T) {
|
|||||||
|
|
||||||
func TestDismissHandler_ReappearsAfterNewWebhook(t *testing.T) {
|
func TestDismissHandler_ReappearsAfterNewWebhook(t *testing.T) {
|
||||||
diun.UpdatesReset()
|
diun.UpdatesReset()
|
||||||
diun.UpdateEvent(diun.DiunEvent{Image: "nginx:latest"})
|
if err := diun.UpdateEvent(diun.DiunEvent{Image: "nginx:latest"}); err != nil {
|
||||||
|
t.Fatalf("test setup: UpdateEvent failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
req := httptest.NewRequest(http.MethodPatch, "/api/updates/nginx:latest", nil)
|
req := httptest.NewRequest(http.MethodPatch, "/api/updates/nginx:latest", nil)
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
|
|||||||
Reference in New Issue
Block a user