mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
Merge pull request #1556 from VaibhavMalik4187/locationresolver-tests
Added missing tests for locationresolver
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
@
|
||||
Reference in New Issue
Block a user