1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/pkg/signal/signal_test.go
Naveed Jamil 4b0df45c1a Add test coverage to pkg/signal
Signed-off-by: Naveed Jamil <naveed.jamil@tenpearls.com>
2017-06-01 14:53:15 +05:00

33 lines
802 B
Go

package signal
import (
"syscall"
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseSignal(t *testing.T) {
_, checkAtoiError := ParseSignal("0")
assert.EqualError(t, checkAtoiError, "Invalid signal: 0")
_, error := ParseSignal("SIG")
assert.EqualError(t, error, "Invalid signal: SIG")
for sigStr := range SignalMap {
responseSignal, error := ParseSignal(sigStr)
assert.NoError(t, error)
signal := SignalMap[sigStr]
assert.EqualValues(t, signal, responseSignal)
}
}
func TestValidSignalForPlatform(t *testing.T) {
isValidSignal := ValidSignalForPlatform(syscall.Signal(0))
assert.EqualValues(t, false, isValidSignal)
for _, sigN := range SignalMap {
isValidSignal = ValidSignalForPlatform(syscall.Signal(sigN))
assert.EqualValues(t, true, isValidSignal)
}
}