You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.9 KiB
65 lines
1.9 KiB
5 years ago
|
package nodeconfig
|
||
6 years ago
|
|
||
|
import "testing"
|
||
|
|
||
|
func TestGroupID_String(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
name string
|
||
|
id GroupID
|
||
|
want string
|
||
|
}{
|
||
|
{"empty", GroupID(""), ""},
|
||
6 years ago
|
{"ABC", GroupID("ABC"), "ABC"},
|
||
6 years ago
|
}
|
||
|
for _, tt := range tests {
|
||
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
if got := tt.id.String(); got != tt.want {
|
||
|
t.Errorf("GroupID.String() = %v, want %v", got, tt.want)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|
||
6 years ago
|
|
||
|
func TestActionTypeString(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
name string
|
||
|
actionType ActionType
|
||
|
expectedActionName string
|
||
|
}{
|
||
|
{"ActionStart", ActionStart, "ActionStart"},
|
||
|
{"ActionPause", ActionPause, "ActionPause"},
|
||
|
{"ActionResume", ActionResume, "ActionResume"},
|
||
|
{"ActionStop", ActionStop, "ActionStop"},
|
||
|
{"UnknownAction", ActionType(8), "ActionUnknown"},
|
||
|
}
|
||
|
for _, tt := range tests {
|
||
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
if got := tt.actionType.String(); got != tt.expectedActionName {
|
||
|
t.Errorf("ActionType.String() = %v, expected %v", got, tt.expectedActionName)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestGroupAction(t *testing.T) {
|
||
6 years ago
|
tests := []struct {
|
||
|
name string
|
||
|
groupAction GroupAction
|
||
|
expectedGroupActionName string
|
||
|
}{
|
||
6 years ago
|
{"BeaconStart", GroupAction{Name: GroupID("ABC"), Action: ActionStart}, "ABC/ActionStart"},
|
||
|
{"BeaconPause", GroupAction{Name: GroupID("ABC"), Action: ActionPause}, "ABC/ActionPause"},
|
||
|
{"BeaconResume", GroupAction{Name: GroupID("ABC"), Action: ActionResume}, "ABC/ActionResume"},
|
||
|
{"BeaconStop", GroupAction{Name: GroupID("ABC"), Action: ActionStop}, "ABC/ActionStop"},
|
||
|
{"BeaconUnknown", GroupAction{Name: GroupID("ABC"), Action: ActionType(8)}, "ABC/ActionUnknown"},
|
||
6 years ago
|
}
|
||
|
for _, tt := range tests {
|
||
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
if got := tt.groupAction.String(); got != tt.expectedGroupActionName {
|
||
|
t.Errorf("ActionType.String() = %v, expected %v", got, tt.expectedGroupActionName)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
6 years ago
|
|
||
|
}
|