diff --git a/core/cautils/fileutils_test.go b/core/cautils/fileutils_test.go index b132f75a..ee08e2aa 100644 --- a/core/cautils/fileutils_test.go +++ b/core/cautils/fileutils_test.go @@ -27,7 +27,7 @@ func TestListFiles(t *testing.T) { files, errs := listFiles(filesPath) assert.Equal(t, 0, len(errs)) - assert.Equal(t, 12, len(files)) + assert.Equal(t, 13, len(files)) } func TestLoadResourcesFromFiles(t *testing.T) { diff --git a/core/pkg/resultshandling/locationresolver/locationresolver_test.go b/core/pkg/resultshandling/locationresolver/locationresolver_test.go index 2a3551e5..f1e7c2bb 100644 --- a/core/pkg/resultshandling/locationresolver/locationresolver_test.go +++ b/core/pkg/resultshandling/locationresolver/locationresolver_test.go @@ -37,6 +37,12 @@ func TestResolveLocation(t *testing.T) { resolver, _ := NewFixPathLocationResolver(yamlFilePath) + for fixPath, _ := range fixPathToExpectedLineAndColumn { + location, err := resolver.ResolveLocation(fixPath, 100000) + assert.Contains(t, err.Error(), "node index [100000] out of range ") + assert.Empty(t, location) + } + for fixPath, expected := range fixPathToExpectedLineAndColumn { location, err := resolver.ResolveLocation(fixPath, 0) assert.NoError(t, err) @@ -62,3 +68,17 @@ func TestResolveLocation(t *testing.T) { assert.ErrorContains(t, err, "invalid input") } + +func TestFixPathLocationResolver_NonExistentYaml(t *testing.T) { + yamlFilePath := filepath.Join(onlineBoutiquePath(), "adservice_invalid.yaml") + resolver, err := NewFixPathLocationResolver(yamlFilePath) + assert.Nil(t, resolver) + assert.NotNil(t, err) +} + +func TestFixPathLocationResolver_InvalidYaml(t *testing.T) { + yamlFilePath := filepath.Join(onlineBoutiquePath(), "invalid.yaml") + resolver, err := NewFixPathLocationResolver(yamlFilePath) + assert.Nil(t, resolver) + assert.NotNil(t, err) +} diff --git a/examples/online-boutique/invalid.yaml b/examples/online-boutique/invalid.yaml new file mode 100644 index 00000000..b516b2c4 --- /dev/null +++ b/examples/online-boutique/invalid.yaml @@ -0,0 +1 @@ +@ \ No newline at end of file