@@ -9,7 +9,7 @@ module Oracle.Validate.Requests.TestRun.Create
9
9
10
10
import Control.Monad (when )
11
11
import Control.Monad.Trans.Class (lift )
12
- import Core.Types.Basic (Commit , Directory (.. ), Duration (.. ), Repository , Try (.. ))
12
+ import Core.Types.Basic (Commit ( .. ) , Directory (.. ), Duration (.. ), Repository ( .. ) , Try (.. ))
13
13
import Core.Types.Change (Change (.. ), Key (.. ))
14
14
import Core.Types.Fact (Fact (.. ))
15
15
import Core.Types.Operation (Op (.. ), Operation (.. ))
@@ -106,7 +106,7 @@ validateCreateTestRun
106
106
data TestRunRejection
107
107
= UnacceptableDuration Int Int
108
108
| UnacceptableCommit Repository Commit
109
- | UnacceptableTryIndex
109
+ | UnacceptableTryIndex Try
110
110
| UnacceptableRole
111
111
| NoRegisteredKeyVerifiesTheSignature
112
112
| UserHasNoRegisteredSSHKeys
@@ -119,10 +119,10 @@ data TestRunRejection
119
119
instance Monad m => ToJSON m TestRunRejection where
120
120
toJSON (UnacceptableDuration minDuration maxDuration) =
121
121
stringJSON $ " unacceptable duration. Expecting duration to be between " <> show minDuration <> " and " <> show maxDuration
122
- toJSON (UnacceptableCommit repo commit)=
123
- stringJSON $ " unacceptable commit. The specified commit " <> show commit<> " cannot be found in the repository " <> show repo
124
- toJSON UnacceptableTryIndex =
125
- stringJSON " unacceptable try index"
122
+ toJSON (UnacceptableCommit ( Repository org repo) ( Commit commit) )=
123
+ stringJSON $ " unacceptable commit. The specified commit " <> show commit<> " cannot be found in the repository " <> show org <> " / " <> show repo
124
+ toJSON ( UnacceptableTryIndex ( Try maxIx)) =
125
+ stringJSON $ " unacceptable try index. Expecting at most " <> show maxIx <> " run attempts for a given commit "
126
126
toJSON UnacceptableRole =
127
127
stringJSON " unacceptable role"
128
128
toJSON NoRegisteredKeyVerifiesTheSignature =
@@ -194,7 +194,7 @@ checkTryIndex
194
194
195
195
if tryIndex testRun == succ latest
196
196
then return Nothing
197
- else return $ Just UnacceptableTryIndex
197
+ else return $ Just ( UnacceptableTryIndex latest)
198
198
199
199
checkCommit
200
200
:: Monad m
0 commit comments