Skip to content

Commit 6603873

Browse files
committed
improve UnacceptableDuration
1 parent 92aaca6 commit 6603873

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

cli/src/Oracle/Validate/Requests/TestRun/Create.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ validateCreateTestRun
104104
testRunState
105105

106106
data TestRunRejection
107-
= UnacceptableDuration
107+
= UnacceptableDuration Int Int
108108
| UnacceptableCommit
109109
| UnacceptableTryIndex
110110
| UnacceptableRole
@@ -117,8 +117,8 @@ data TestRunRejection
117117
deriving (Eq, Show)
118118

119119
instance Monad m => ToJSON m TestRunRejection where
120-
toJSON UnacceptableDuration =
121-
stringJSON "unacceptable duration"
120+
toJSON (UnacceptableDuration minDuration maxDuration) =
121+
stringJSON $ "unacceptable duration. Expecting duration to be between "<> show minDuration <> " and "<>show maxDuration
122122
toJSON UnacceptableCommit =
123123
stringJSON "unacceptable commit"
124124
toJSON UnacceptableTryIndex =
@@ -141,7 +141,8 @@ instance Monad m => ToJSON m TestRunRejection where
141141
checkDuration
142142
:: TestRunValidationConfig -> Duration -> Maybe TestRunRejection
143143
checkDuration TestRunValidationConfig{maxDuration, minDuration} (Duration n)
144-
| n < minDuration || n > maxDuration = Just UnacceptableDuration
144+
| n < minDuration || n > maxDuration =
145+
Just $ UnacceptableDuration minDuration maxDuration
145146
| otherwise = Nothing
146147

147148
checkRole

cli/test/Oracle/Validate/Requests/TestRun/CreateSpec.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,11 @@ spec = do
249249
(mkValidation mockMPFS noValidation)
250250
testRun
251251
testRunState
252-
onConditionHaveReason mresult UnacceptableDuration
253-
$ duration < minDuration testConfig
254-
|| duration > maxDuration testConfig
252+
let expectedMinDuration = minDuration testConfig
253+
let expectedMaxDuration = maxDuration testConfig
254+
onConditionHaveReason mresult (UnacceptableDuration expectedMinDuration expectedMaxDuration)
255+
$ duration < expectedMinDuration
256+
|| duration > expectedMaxDuration
255257

256258
it "reports unacceptable role" $ egenProperty $ do
257259
testConfig <- testConfigEGen

0 commit comments

Comments
 (0)