Merge pull request #1556 from VaibhavMalik4187/locationresolver-tests

Added missing tests for locationresolver
This commit is contained in:
Matthias Bertschy
2024-01-03 15:49:40 +01:00
committed by GitHub
3 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -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) {
@@ -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)
}
+1
View File
@@ -0,0 +1 @@
@