File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 1
1
module User.Agent.Lib
2
2
( resolveTestRunId
3
3
, withState
4
+ , testRunDuration
4
5
) where
5
6
6
7
import Control.Applicative (Alternative (.. ))
7
8
import Core.Context (WithContext , withMPFS )
8
- import Core.Types.Basic (TokenId )
9
+ import Core.Types.Basic (Duration , TokenId )
9
10
import Core.Types.Fact (Fact (.. ), keyHash , parseFacts )
10
11
import Data.Foldable (find )
11
12
import MPFS.API (MPFS (.. ))
12
13
import Text.JSON.Canonical (FromJSON (.. ), JSValue )
13
14
import User.Agent.Types (TestRunId (.. ))
14
- import User.Types (Phase (.. ), TestRun , TestRunState )
15
+ import User.Types (Phase (.. ), TestRun , TestRunState ( .. ) )
15
16
16
17
resolveTestRunId
17
18
:: forall s m
@@ -42,3 +43,9 @@ withState f v =
42
43
state
43
44
:: forall s . FromJSON Maybe (TestRunState s ) => Maybe (TestRunState s )
44
45
state = fromJSON v
46
+
47
+ testRunDuration :: TestRunState v -> Duration
48
+ testRunDuration (Pending d _) = d
49
+ testRunDuration (Rejected pending _) = testRunDuration pending
50
+ testRunDuration (Accepted pending) = testRunDuration pending
51
+ testRunDuration (Finished accepted _ _) = testRunDuration accepted
Original file line number Diff line number Diff line change @@ -52,11 +52,11 @@ import Text.JSON.Canonical
52
52
, ToJSON (.. )
53
53
, renderCanonicalJSON
54
54
)
55
- import User.Agent.Lib (resolveTestRunId , withState )
55
+ import User.Agent.Lib (resolveTestRunId , testRunDuration , withState )
56
56
import User.Agent.Types
57
57
( TestRunId (.. )
58
58
)
59
- import User.Types (TestRun (.. ), TestRunState ( .. ) )
59
+ import User.Types (TestRun (.. ))
60
60
61
61
dockerfile :: String
62
62
dockerfile =
@@ -195,12 +195,6 @@ collectImagesFromAssets (Directory dirname) = do
195
195
let images = nub . sort . filter (not . null ) . lines
196
196
return $ output <&> images
197
197
198
- pickDuration :: TestRunState v -> Duration
199
- pickDuration (Pending d _) = d
200
- pickDuration (Rejected pending _) = pickDuration pending
201
- pickDuration (Accepted pending) = pickDuration pending
202
- pickDuration (Finished accepted _ _) = pickDuration accepted
203
-
204
198
getTestRun
205
199
:: Monad m
206
200
=> TokenId
@@ -213,7 +207,7 @@ getTestRun tk testRunId = do
213
207
mts <- lift $ resolveTestRunId tk testRunId
214
208
Fact tr v <- liftMaybe (Couldn'tResolveTestRunId testRunId) mts
215
209
liftMaybe (Couldn'tResolveTestRunId testRunId)
216
- $ withState (\ state -> (tr, pickDuration state)) v
210
+ $ withState (\ state -> (tr, testRunDuration state)) v
217
211
218
212
data AntithesisAuth = AntithesisAuth
219
213
{ username :: String
You can’t perform that action at this time.
0 commit comments