airshipctl/pkg/remote/power/status_test.go
Drew Walters 69e8c886fe Add strong typing for baremetal power statuses
Baremetal host power statuses are handled as strings in airshipctl.
Invoking remotedirect on a host that is powered off will result in a
remotedirect failure; therefore, the power status of a host needs to be
verified before remotedirect can begin. This change adds strict typing
to baremetal power statuses so airshipctl can verify the status of a
remote host before performing remotedirect regardless of the client type
(e.g. redfish, other).

Change-Id: I22f1784006add018ee1d67c18f94499aa9544752
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-01 17:25:31 +00:00

57 lines
1.2 KiB
Go

/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package power
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestStatus(t *testing.T) {
tests := []struct {
name string
status Status
}{
{
name: "StatusUnknown",
status: StatusUnknown,
},
{
name: "StatusOn",
status: StatusOn,
},
{
name: "StatusOff",
status: StatusOff,
},
{
name: "StatusPoweringOn",
status: StatusPoweringOn,
},
{
name: "StatusPoweringOff",
status: StatusPoweringOff,
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, statusMap[test.status], test.status.String())
})
}
}