Fixed lint tests

dev
Ice3man543 2021-07-02 15:46:42 +05:30
parent cddb0cb8af
commit 714aec1219
1 changed files with 7 additions and 10 deletions

View File

@ -3,41 +3,38 @@ package loader
import (
"testing"
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/config"
"github.com/stretchr/testify/require"
)
func TestLoadTemplates(t *testing.T) {
config, err := config.ReadConfiguration()
require.Nil(t, err, "could not read configuration")
store, err := New(&Config{
Templates: []string{"cves/CVE-2021-21315.yaml"},
})
require.Nil(t, err, "could not load templates")
require.Equal(t, []string{"cves/CVE-2021-21315.yaml"}, store.finalTemplates, "could not get correct templates")
templatesDirectory := "/test"
t.Run("blank", func(t *testing.T) {
store, err := New(&Config{
TemplatesDirectory: config.TemplatesDirectory,
TemplatesDirectory: templatesDirectory,
})
require.Nil(t, err, "could not load templates")
require.Equal(t, []string{config.TemplatesDirectory}, store.finalTemplates, "could not get correct templates")
require.Equal(t, []string{templatesDirectory}, store.finalTemplates, "could not get correct templates")
})
t.Run("only-tags", func(t *testing.T) {
store, err := New(&Config{
Tags: []string{"cves"},
TemplatesDirectory: config.TemplatesDirectory,
TemplatesDirectory: templatesDirectory,
})
require.Nil(t, err, "could not load templates")
require.Equal(t, []string{config.TemplatesDirectory}, store.finalTemplates, "could not get correct templates")
require.Equal(t, []string{templatesDirectory}, store.finalTemplates, "could not get correct templates")
})
t.Run("tags-with-path", func(t *testing.T) {
store, err := New(&Config{
Tags: []string{"cves"},
TemplatesDirectory: config.TemplatesDirectory,
TemplatesDirectory: templatesDirectory,
})
require.Nil(t, err, "could not load templates")
require.Equal(t, []string{config.TemplatesDirectory}, store.finalTemplates, "could not get correct templates")
require.Equal(t, []string{templatesDirectory}, store.finalTemplates, "could not get correct templates")
})
}