11package vmstatus
22
33import (
4+ "reflect"
45 "testing"
56 "time"
67
78 etypes "github.com/chaitin/MonkeyCode/backend/ent/types"
89 "github.com/chaitin/MonkeyCode/backend/pkg/taskflow"
910)
1011
12+ func TestInputDoesNotExposeReportedStatus (t * testing.T ) {
13+ if _ , ok := reflect .TypeOf (Input {}).FieldByName ("ReportedStatus" ); ok {
14+ t .Fatal ("Input should not expose ReportedStatus" )
15+ }
16+ }
17+
1118func TestResolve (t * testing.T ) {
1219 now := time .Date (2026 , 4 , 15 , 12 , 0 , 0 , 0 , time .UTC )
1320
@@ -19,29 +26,27 @@ func TestResolve(t *testing.T) {
1926 {
2027 name : "is recycled overrides everything" ,
2128 input : Input {
22- ReportedStatus : taskflow .VirtualMachineStatusOnline ,
23- Online : true ,
24- IsRecycled : true ,
25- CreatedAt : now .Add (- 10 * time .Minute ),
26- Now : now ,
29+ Online : true ,
30+ IsRecycled : true ,
31+ CreatedAt : now .Add (- 10 * time .Minute ),
32+ Now : now ,
2733 },
2834 want : taskflow .VirtualMachineStatusOffline ,
2935 },
3036 {
31- name : "reported status wins over online and conditions" ,
37+ name : "online returns online before conditions" ,
3238 input : Input {
33- ReportedStatus : taskflow .VirtualMachineStatusHibernated ,
34- Online : true ,
39+ Online : true ,
3540 Conditions : []* etypes.Condition {
3641 {Type : etypes .ConditionTypeFailed },
3742 },
3843 CreatedAt : now .Add (- 10 * time .Minute ),
3944 Now : now ,
4045 },
41- want : taskflow .VirtualMachineStatusHibernated ,
46+ want : taskflow .VirtualMachineStatusOnline ,
4247 },
4348 {
44- name : "online returns online when no reported status " ,
49+ name : "online returns online" ,
4550 input : Input {
4651 Online : true ,
4752 CreatedAt : now .Add (- 10 * time .Minute ),
0 commit comments