-
Notifications
You must be signed in to change notification settings - Fork 2
/
power_test.go
38 lines (33 loc) · 1.54 KB
/
power_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package amt
import (
"testing"
"github.com/ammmze/go-amt/cim"
"github.com/stretchr/testify/assert"
)
func TestSelectNextState_When_NoneOfTheRequestedStatesAreAvailable_Expect_Unknown(t *testing.T) {
availableStates := []cim.RequestedPowerState{cim.RequestedPowerStateOn}
nextState := selectNextState(getPowerOffStates(), availableStates)
assert.Equal(t, cim.RequestedPowerStateUnknown, nextState)
}
func TestSelectNextState_When_OneOfTheRequestedStatesAreAvailable_Expect_RequestedState(t *testing.T) {
requestedStates := getPowerOffStates()
availableStates := []cim.RequestedPowerState{requestedStates[0]}
nextState := selectNextState(requestedStates, availableStates)
assert.Equal(t, requestedStates[0], nextState)
}
func TestSelectNextState_When_MultipleOfTheRequestedStatesAreAvailable_Expect_FirstAvailableRequestedState(t *testing.T) {
requestedStates := getPowerOffStates()
availableStates := []cim.RequestedPowerState{requestedStates[1], requestedStates[2]}
nextState := selectNextState(requestedStates, availableStates)
assert.Equal(t, requestedStates[1], nextState)
}
func TestIsPoweredOnGivenStatus_When_powerStateOn_Expect_True(t *testing.T) {
status := &cim.AssociatedPowerManagementServiceType{PowerState: cim.PowerStateOn}
actual := isPoweredOnGivenStatus(status)
assert.Equal(t, true, actual)
}
func TestIsPoweredOnGivenStatus_When_powerStateOffSoft_Expect_False(t *testing.T) {
status := &cim.AssociatedPowerManagementServiceType{PowerState: cim.PowerStateOffSoft}
actual := isPoweredOnGivenStatus(status)
assert.Equal(t, false, actual)
}