mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 15:06:36 +01:00
--------- Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package options
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/anchore/syft/syft/cataloging"
|
|
)
|
|
|
|
func Test_golangConfig_PostLoad(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
cfg golangConfig
|
|
expected cataloging.SymbolScope
|
|
wantErr assert.ErrorAssertionFunc
|
|
}{
|
|
{
|
|
name: "normalize all",
|
|
cfg: golangConfig{CaptureSymbols: "all"},
|
|
expected: cataloging.SymbolScopeAll,
|
|
},
|
|
{
|
|
name: "normalize stdlib",
|
|
cfg: golangConfig{CaptureSymbols: "stdlib"},
|
|
expected: cataloging.SymbolScopeStdlib,
|
|
},
|
|
{
|
|
name: "empty defaults to none",
|
|
cfg: golangConfig{CaptureSymbols: ""},
|
|
expected: cataloging.SymbolScopeNone,
|
|
},
|
|
{
|
|
name: "invalid value defaults to none",
|
|
cfg: golangConfig{CaptureSymbols: "bogus"},
|
|
expected: cataloging.SymbolScopeNone,
|
|
},
|
|
{
|
|
name: "boolean spellings default to none",
|
|
cfg: golangConfig{CaptureSymbols: "true"},
|
|
expected: cataloging.SymbolScopeNone,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if tt.wantErr == nil {
|
|
tt.wantErr = assert.NoError
|
|
}
|
|
err := tt.cfg.PostLoad()
|
|
tt.wantErr(t, err)
|
|
if err != nil {
|
|
return
|
|
}
|
|
assert.Equal(t, tt.expected, tt.cfg.CaptureSymbols)
|
|
})
|
|
}
|
|
}
|