Debian Codegraph @

v2/sarif/artifact_change_test.go

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