mirror of
https://github.com/Icinga/icingadb.git
synced 2026-02-18 18:18:00 -05:00
Test types.AcknowledgementState#Value()
This commit is contained in:
parent
cb9de115e2
commit
90c2499dfd
1 changed files with 26 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -35,3 +36,28 @@ func TestAcknowledgementState_UnmarshalJSON(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAcknowledgementState_Value(t *testing.T) {
|
||||
subtests := []struct {
|
||||
name string
|
||||
input AcknowledgementState
|
||||
output driver.Value
|
||||
error bool
|
||||
}{
|
||||
{name: "invalid", input: 3, error: true},
|
||||
{name: "n", input: 0, output: "n"},
|
||||
{name: "y", input: 1, output: "y"},
|
||||
{name: "sticky", input: 2, output: "sticky"},
|
||||
}
|
||||
|
||||
for _, st := range subtests {
|
||||
t.Run(st.name, func(t *testing.T) {
|
||||
if v, err := st.input.Value(); st.error {
|
||||
require.Error(t, err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, st.output, v)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue