github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/pkg/signal/signal_test.go (about)

     1  package signal
     2  
     3  import (
     4  	"syscall"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestParseSignal(t *testing.T) {
    11  	_, checkAtoiError := ParseSignal("0")
    12  	assert.EqualError(t, checkAtoiError, "Invalid signal: 0")
    13  
    14  	_, error := ParseSignal("SIG")
    15  	assert.EqualError(t, error, "Invalid signal: SIG")
    16  
    17  	for sigStr := range SignalMap {
    18  		responseSignal, error := ParseSignal(sigStr)
    19  		assert.NoError(t, error)
    20  		signal := SignalMap[sigStr]
    21  		assert.EqualValues(t, signal, responseSignal)
    22  	}
    23  }
    24  
    25  func TestValidSignalForPlatform(t *testing.T) {
    26  	isValidSignal := ValidSignalForPlatform(syscall.Signal(0))
    27  	assert.EqualValues(t, false, isValidSignal)
    28  
    29  	for _, sigN := range SignalMap {
    30  		isValidSignal = ValidSignalForPlatform(syscall.Signal(sigN))
    31  		assert.EqualValues(t, true, isValidSignal)
    32  	}
    33  }