github.com/devseccon/trivy@v0.47.1-0.20231123133102-bd902a0bd996/pkg/fanal/analyzer/config/terraformplan/terraformplan_test.go (about) 1 package terraformplan 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestConfigAnalyzer_Required(t *testing.T) { 10 tests := []struct { 11 name string 12 filePath string 13 want bool 14 }{ 15 { 16 name: "happy path", 17 filePath: "/path/to/tfplan.json", 18 want: true, 19 }, 20 { 21 name: "hcl", 22 filePath: "/path/to/main.hcl", 23 want: false, 24 }, 25 { 26 name: "yaml", 27 filePath: "deployment.yaml", 28 want: false, 29 }, 30 } 31 for _, tt := range tests { 32 t.Run(tt.name, func(t *testing.T) { 33 a := terraformPlanConfigAnalyzer{} 34 got := a.Required(tt.filePath, nil) 35 assert.Equal(t, tt.want, got) 36 }) 37 } 38 }