1
0
mirror of https://github.com/nxshock/gron.git synced 2024-11-27 03:41:00 +05:00
gron/restartrule_test.go

41 lines
721 B
Go
Raw Permalink Normal View History

2022-03-29 21:38:04 +05:00
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRestartRuleMarshalText(t *testing.T) {
var tests = []struct {
expected []byte
value RestartRule
}{
{[]byte("no"), No},
{[]byte("on-error"), OnError},
}
for _, test := range tests {
got, err := test.value.MarshalText()
assert.NoError(t, err)
assert.Equal(t, test.expected, got)
}
}
func TestRestartRuleUnmarshalText(t *testing.T) {
var tests = []struct {
expected RestartRule
value []byte
}{
{No, []byte("no")},
{OnError, []byte("on-error")},
}
for _, test := range tests {
var r RestartRule
err := r.UnmarshalText(test.value)
assert.NoError(t, err)
assert.Equal(t, test.expected, r)
}
}