This PR refactors most of the internals to make them easier to test (and also because the names didn't make sense). It adds unit tests for all internal components. Reviewed-on: #2 Co-authored-by: Emmanuel BENOÎT <tseeker@nocternity.net> Co-committed-by: Emmanuel BENOÎT <tseeker@nocternity.net>
26 lines
647 B
Go
26 lines
647 B
Go
package results // import nocternity.net/gomonop/pkg/results
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestStatusDefaultOK(t *testing.T) {
|
|
var s Status
|
|
assert.Equal(t, StatusOK, s)
|
|
}
|
|
|
|
func TestStatusToString(t *testing.T) {
|
|
assert.Equal(t, "OK", StatusOK.String())
|
|
assert.Equal(t, "WARNING", StatusWarning.String())
|
|
assert.Equal(t, "ERROR", StatusCritical.String())
|
|
assert.Equal(t, "UNKNOWN", StatusUnknown.String())
|
|
}
|
|
|
|
func TestStatusToInt(t *testing.T) {
|
|
assert.Equal(t, 0, int(StatusOK))
|
|
assert.Equal(t, 1, int(StatusWarning))
|
|
assert.Equal(t, 2, int(StatusCritical))
|
|
assert.Equal(t, 3, int(StatusUnknown))
|
|
}
|