add a github actions config (#985)

* add a github actions config

* fix(log): Don't create a log dir when testing

* remove a meaningless test case

* Thanks for everything, Mr, Travys.

* add golangci

* add goreleaser.yml

* add tidy.yml

* add golang-ci

* fix many lint warnings
This commit is contained in:
Kota Kanbe
2020-05-27 20:11:24 +09:00
committed by GitHub
parent 2374f578ed
commit 62c9409fe9
32 changed files with 233 additions and 216 deletions

View File

@@ -4,56 +4,9 @@ import (
"reflect"
"testing"
"github.com/aquasecurity/trivy-db/pkg/db"
"github.com/aquasecurity/trivy/pkg/log"
"github.com/aquasecurity/trivy/pkg/types"
"github.com/aquasecurity/trivy/pkg/utils"
)
func TestScan(t *testing.T) {
var tests = []struct {
path string
pkgs []types.Library
}{
{
path: "app/package-lock.json",
pkgs: []types.Library{
{
Name: "jquery",
Version: "2.2.4",
},
{
Name: "@babel/traverse",
Version: "7.4.4",
},
},
},
}
if err := log.InitLogger(false, false); err != nil {
t.Errorf("trivy logger failed")
}
cacheDir := utils.DefaultCacheDir()
if err := db.Init(cacheDir); err != nil {
t.Errorf("trivy db.Init failed")
}
for _, v := range tests {
lib := LibraryScanner{
Path: v.path,
Libs: v.pkgs,
}
actual, err := lib.Scan()
if err != nil {
t.Errorf("error occurred")
}
if len(actual) == 0 {
t.Errorf("no vuln found : actual: %v\n", actual)
}
}
db.Close()
}
func TestLibraryScanners_Find(t *testing.T) {
type args struct {
name string