@@ -29,7 +29,7 @@ func TestScriptCompleted(t *testing.T) {
29
29
Stage : agentproto .Timing_START ,
30
30
Start : timestamppb .New (dbtime .Now ()),
31
31
End : timestamppb .New (dbtime .Now ().Add (time .Second )),
32
- TimedOut : false ,
32
+ Status : agentproto . Timing_OK ,
33
33
ExitCode : 0 ,
34
34
},
35
35
},
@@ -39,7 +39,7 @@ func TestScriptCompleted(t *testing.T) {
39
39
Stage : agentproto .Timing_STOP ,
40
40
Start : timestamppb .New (dbtime .Now ()),
41
41
End : timestamppb .New (dbtime .Now ().Add (time .Second )),
42
- TimedOut : false ,
42
+ Status : agentproto . Timing_OK ,
43
43
ExitCode : 0 ,
44
44
},
45
45
},
@@ -49,7 +49,7 @@ func TestScriptCompleted(t *testing.T) {
49
49
Stage : agentproto .Timing_CRON ,
50
50
Start : timestamppb .New (dbtime .Now ()),
51
51
End : timestamppb .New (dbtime .Now ().Add (time .Second )),
52
- TimedOut : false ,
52
+ Status : agentproto . Timing_OK ,
53
53
ExitCode : 0 ,
54
54
},
55
55
},
@@ -59,7 +59,7 @@ func TestScriptCompleted(t *testing.T) {
59
59
Stage : agentproto .Timing_START ,
60
60
Start : timestamppb .New (dbtime .Now ()),
61
61
End : timestamppb .New (dbtime .Now ().Add (time .Second )),
62
- TimedOut : true ,
62
+ Status : agentproto . Timing_TIMED_OUT ,
63
63
ExitCode : 255 ,
64
64
},
65
65
},
@@ -69,7 +69,7 @@ func TestScriptCompleted(t *testing.T) {
69
69
Stage : agentproto .Timing_START ,
70
70
Start : timestamppb .New (dbtime .Now ()),
71
71
End : timestamppb .New (dbtime .Now ().Add (time .Second )),
72
- TimedOut : true ,
72
+ Status : agentproto . Timing_EXIT_FAILURE ,
73
73
ExitCode : 1 ,
74
74
},
75
75
},
@@ -83,9 +83,9 @@ func TestScriptCompleted(t *testing.T) {
83
83
mDB .EXPECT ().InsertWorkspaceAgentScriptTimings (gomock .Any (), database.InsertWorkspaceAgentScriptTimingsParams {
84
84
ScriptID : tt .scriptID ,
85
85
Stage : protoScriptTimingStageToDatabase (tt .timing .Stage ),
86
+ Status : protoScriptTimingStatusToDatabase (tt .timing .Status ),
86
87
StartedAt : tt .timing .Start .AsTime (),
87
88
EndedAt : tt .timing .End .AsTime (),
88
- TimedOut : tt .timing .TimedOut ,
89
89
ExitCode : tt .timing .ExitCode ,
90
90
})
91
91
@@ -108,3 +108,18 @@ func protoScriptTimingStageToDatabase(stage agentproto.Timing_Stage) database.Wo
108
108
}
109
109
return dbStage
110
110
}
111
+
112
+ func protoScriptTimingStatusToDatabase (stage agentproto.Timing_Status ) database.WorkspaceAgentScriptTimingStatus {
113
+ var dbStatus database.WorkspaceAgentScriptTimingStatus
114
+ switch stage {
115
+ case agentproto .Timing_OK :
116
+ dbStatus = database .WorkspaceAgentScriptTimingStatusOk
117
+ case agentproto .Timing_EXIT_FAILURE :
118
+ dbStatus = database .WorkspaceAgentScriptTimingStatusExitFailure
119
+ case agentproto .Timing_TIMED_OUT :
120
+ dbStatus = database .WorkspaceAgentScriptTimingStatusTimedOut
121
+ case agentproto .Timing_PIPES_LEFT_OPEN :
122
+ dbStatus = database .WorkspaceAgentScriptTimingStatusPipesLeftOpen
123
+ }
124
+ return dbStatus
125
+ }
0 commit comments