* Normalize event configuration This updates event configuration stanzas to more closely match behavior for listeners and kmses: * Singular "sink" instead of "sinks" (probably not the most correct option, but a consistent option, and one that makes sense for HCL) * Allows sinks to have the type defined at the start of the block * Moves type-specific configuration to a specific named block Co-authored-by: Jim <jlambert@hashicorp.com>
51 lines
966 B
Go
51 lines
966 B
Go
package event
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestEventerConfig_Validate(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
c EventerConfig
|
|
wantErrIs error
|
|
wantErrContains string
|
|
}{
|
|
{
|
|
name: "invalid-sink",
|
|
c: EventerConfig{
|
|
Sinks: []SinkConfig{
|
|
{
|
|
Type: "invalid",
|
|
},
|
|
},
|
|
},
|
|
wantErrIs: ErrInvalidParameter,
|
|
wantErrContains: "is not a valid sink type",
|
|
},
|
|
{
|
|
name: "valid-with-all-defaults",
|
|
c: EventerConfig{},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
assert, require := assert.New(t), require.New(t)
|
|
err := tt.c.Validate()
|
|
if tt.wantErrIs != nil {
|
|
require.Error(err)
|
|
assert.ErrorIs(err, tt.wantErrIs)
|
|
if tt.wantErrContains != "" {
|
|
assert.Contains(err.Error(), tt.wantErrContains)
|
|
}
|
|
return
|
|
}
|
|
assert.NoError(err)
|
|
})
|
|
}
|
|
}
|