| 1 | package sarif |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/stretchr/testify/assert" |
| 7 | ) |
| 8 | |
| 9 | func Test_create_simple_fix(t *testing.T) { |
| 10 | fix := NewFix(). |
| 11 | WithDescription(NewMessage(). |
| 12 | WithText("fix text")). |
| 13 | WithArtifactChanges([]*ArtifactChange{ |
| 14 | NewArtifactChange( |
| 15 | NewArtifactLocation(). |
| 16 | WithUri("file://broken.go"), |
| 17 | ).WithReplacement( |
| 18 | NewReplacement(NewRegion(). |
| 19 | WithStartLine(10). |
| 20 | WithEndLine(11), |
| 21 | ), |
| 22 | ), |
| 23 | }) |
| 24 | |
| 25 | assert.Equal(t, `{"description":{"text":"fix text"},"artifactChanges":[{"artifactLocation":{"uri":"file://broken.go"},"replacements":[{"deletedRegion":{"startLine":10,"endLine":11}}]}]}`, getJsonString(fix)) |
| 26 | } |