Files
Charon/backend/internal/api/handlers/notification_provider_handler_validation_test.go
GitHub Actions 716ec91f8f chore: Enhance test coverage across various handlers and services
- Added tests for transient SQLite errors in emergency_handler_test.go.
- Introduced validation tests for provider errors in notification_provider_handler_validation_test.go.
- Implemented helper tests for settings handling in settings_handler_helpers_test.go.
- Expanded backup_handler_test.go to include SQLite database setup and validation.
- Improved system_permissions_handler_test.go with additional path repair tests.
- Updated backup_service_test.go to ensure proper database handling and error checks during backup operations.
- Refined import_handler_test.go with additional session validation tests.
2026-02-16 20:32:16 +00:00

33 lines
964 B
Go

package handlers
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
)
func TestIsProviderValidationError(t *testing.T) {
t.Parallel()
tests := []struct {
name string
err error
want bool
}{
{name: "nil", err: nil, want: false},
{name: "invalid custom template", err: errors.New("invalid custom template: parse failed"), want: true},
{name: "rendered template", err: errors.New("rendered template invalid JSON"), want: true},
{name: "failed parse", err: errors.New("failed to parse template"), want: true},
{name: "failed render", err: errors.New("failed to render template"), want: true},
{name: "invalid discord url", err: errors.New("invalid Discord webhook URL"), want: true},
{name: "other", err: errors.New("database unavailable"), want: false},
}
for _, testCase := range tests {
t.Run(testCase.name, func(t *testing.T) {
require.Equal(t, testCase.want, isProviderValidationError(testCase.err))
})
}
}