(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestValidationError(t *testing.T) { |
| 15 | t.Run("basic validation error", func(t *testing.T) { |
| 16 | err := NewValidationError("title", "", "cannot be empty", "Provide a non-empty title") |
| 17 | |
| 18 | require.Error(t, err) |
| 19 | assert.Contains(t, err.Error(), "Validation failed for field 'title'") |
| 20 | assert.Contains(t, err.Error(), "Reason: cannot be empty") |
| 21 | assert.Contains(t, err.Error(), "Suggestion: Provide a non-empty title") |
| 22 | |
| 23 | // Check timestamp is included |
| 24 | assert.Contains(t, err.Error(), "[") |
| 25 | assert.Contains(t, err.Error(), "T") |
| 26 | }) |
| 27 | |
| 28 | t.Run("validation error with long value", func(t *testing.T) { |
| 29 | longValue := strings.Repeat("a", 200) |
| 30 | err := NewValidationError("body", longValue, "too long", "Shorten the body") |
| 31 | |
| 32 | require.Error(t, err) |
| 33 | // Value should be truncated |
| 34 | assert.Contains(t, err.Error(), "...") |
| 35 | assert.Less(t, len(err.Error()), len(longValue)+200) |
| 36 | }) |
| 37 | |
| 38 | t.Run("validation error without suggestion", func(t *testing.T) { |
| 39 | err := NewValidationError("labels", "invalid", "not allowed", "") |
| 40 | |
| 41 | require.Error(t, err) |
| 42 | assert.Contains(t, err.Error(), "Validation failed") |
| 43 | assert.NotContains(t, err.Error(), "Suggestion:") |
| 44 | }) |
| 45 | } |
| 46 | |
| 47 | func TestFieldLocationAlias(t *testing.T) { |
| 48 | loc := FieldLocation{File: "workflow.md", Line: 12, Column: 4} |
nothing calls this directly
no test coverage detected