Skip to content

Commit 248f8bf

Browse files
committed
Test
1 parent 707c03a commit 248f8bf

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

analyzer_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,42 @@ See the License for the specific language governing permissions and
185185
limitations under the License.`))
186186
require.Nil(t, issue)
187187
}
188+
189+
func TestFix(t *testing.T) {
190+
const src = `// mycompany.net
191+
// SPDX-License-Identifier: Foo
192+
193+
// Package foo
194+
package foo
195+
196+
func Foo() { println("Foo") }
197+
`
198+
199+
a := goheader.New(
200+
goheader.WithTemplate(`{{ MY COMPANY }}
201+
SPDX-License-Identifier: Foo`),
202+
goheader.WithValues(map[string]goheader.Value{
203+
"MY COMPANY": &goheader.ConstValue{
204+
RawValue: "mycompany.com",
205+
},
206+
}))
207+
208+
fset := token.NewFileSet()
209+
file, err := parser.ParseFile(fset, "foo.go", src, parser.ParseComments)
210+
require.NoError(t, err)
211+
212+
issue := a.Analyze(&goheader.Target{
213+
File: file,
214+
Path: t.TempDir(),
215+
})
216+
require.NotNil(t, issue)
217+
require.NotNil(t, issue.Fix())
218+
require.Equal(t, []string{
219+
"// mycompany.net",
220+
"// SPDX-License-Identifier: Foo",
221+
}, issue.Fix().Actual)
222+
require.Equal(t, []string{
223+
"// mycompany.com",
224+
"// SPDX-License-Identifier: Foo",
225+
}, issue.Fix().Expected)
226+
}

0 commit comments

Comments
 (0)