30 lines
598 B
Go
30 lines
598 B
Go
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
||
|
|
||
|
package machine
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func setupModel(initial State) Modeler {
|
||
|
return NewModel(initial)
|
||
|
}
|
||
|
|
||
|
func TestMachineModel(t *testing.T) {
|
||
|
m := setupModel("")
|
||
|
if m == nil {
|
||
|
t.Errorf("Failed creating new model")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestMachineModelChangeState(t *testing.T) {
|
||
|
m := setupModel("")
|
||
|
oldState := m.ChangeState("connected")
|
||
|
if oldState != "" {
|
||
|
t.Errorf("Failed changing state in model")
|
||
|
}
|
||
|
if m.InspectState() != "connected" {
|
||
|
t.Errorf("Failed changing state in model")
|
||
|
}
|
||
|
}
|