-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels_test.go
70 lines (58 loc) · 1.16 KB
/
models_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"errors"
"test/models"
"testing"
)
func TestVanilla(t *testing.T) {
env := models.Machine{}
err := models.Abort(&env)
if err != nil {
t.Errorf("Abort(): %s\n", err)
}
err = models.Clear(&env)
var e *models.InvalidCommand
if !errors.As(err, &e) {
t.Errorf("Clear(): %s\n", err)
}
err = models.Reset(&env)
if !errors.As(err, &e) {
t.Errorf("Reset(): %s\n", err)
}
}
func TestInstantSuccessMachine(t *testing.T) {
env := models.InstantSuccessMachine{}
err := models.Reset(&env)
if err != nil {
t.Errorf("Reset(): %s\n", err)
}
err = models.Start(&env)
if err != nil {
t.Errorf("Start(): %s\n", err)
}
var e *models.InvalidCommand
err = models.Reset(&env)
if !errors.As(err, &e) {
t.Errorf("Reset(): %s\n", err)
}
err = models.Hold(&env)
if err != nil {
t.Errorf("Hold(): %s\n", err)
}
err = models.Unhold(&env)
if err != nil {
t.Errorf("Unhold(): %s\n", err)
}
err = models.Suspend(&env)
if err != nil {
t.Errorf("Suspend(): %s\n", err)
}
err = models.Unsuspend(&env)
if err != nil {
t.Errorf("Unsuspend(): %s\n", err)
}
err = models.Stop(&env)
if err != nil {
t.Errorf("Stop(): %s\n", err)
}
}