@@ -14,7 +14,16 @@ import Distribution.Package (PackageIdentifier(..), mkPackageName, packageId, pa
14
14
import Distribution.Server.Features.PreferredVersions.State (PreferredVersions (.. ), VersionStatus (NormalVersion ), PreferredInfo (.. ))
15
15
import Distribution.Server.Features.ReverseDependencies (ReverseFeature (.. ), ReverseCount (.. ), reverseFeature )
16
16
import Distribution.Server.Features.ReverseDependencies.State (ReverseIndex (.. ), addPackage , constructReverseIndex , emptyReverseIndex , getDependenciesFlat , getDependencies , getDependenciesFlatRaw , getDependenciesRaw )
17
- import Distribution.Server.Features.UserNotify (NotifyData (.. ), NotifyPref (.. ), NotifyRevisionRange , NotifyTriggerBounds (.. ), defaultNotifyPrefs , dependencyReleaseEmails , importNotifyPref , notifyDataToCSV )
17
+ import Distribution.Server.Features.UserNotify
18
+ ( NotifyData (.. )
19
+ , NotifyPref (.. )
20
+ , NotifyRevisionRange
21
+ , NotifyTriggerBounds (.. )
22
+ , defaultNotifyPrefs
23
+ , getUserNotificationsOnRelease
24
+ , importNotifyPref
25
+ , notifyDataToCSV
26
+ )
18
27
import Distribution.Server.Framework.BackupRestore (runRestore )
19
28
import Distribution.Server.Framework.Hook (newHook )
20
29
import Distribution.Server.Framework.MemState (newMemStateWHNF )
@@ -186,7 +195,7 @@ allTests = testGroup "ReverseDependenciesTest"
186
195
ReverseFeature {revDisplayInfo} <- mkRevFeat mtlBeelineLens
187
196
res <- revDisplayInfo
188
197
assertEqual " beeline preferred is old" (PreferredInfo [] [] Nothing , [mkVersion [0 ]]) (res " beeline" )
189
- , testCase " dependencyReleaseEmails sends notification" $ do
198
+ , testCase " getUserNotificationsOnRelease sends notification" $ do
190
199
let userSetIdForPackage arg | arg == mkPackageName " mtl" = Identity (UserIdSet. fromList [UserId 0 ])
191
200
| otherwise = error " should only get user ids for mtl"
192
201
notifyPref triggerBounds =
@@ -197,9 +206,9 @@ allTests = testGroup "ReverseDependenciesTest"
197
206
}
198
207
pref triggerBounds (UserId 0 ) = Identity (Just $ notifyPref triggerBounds)
199
208
pref _ _ = error " should only get preferences for UserId 0"
200
- refNotification base = Map. fromList
209
+ userNotification = Map. fromList
201
210
[
202
- ( ( UserId 0 , base)
211
+ ( UserId 0
203
212
, [PackageIdentifier (mkPackageName " mtl" ) (mkVersion [2 ,3 ])]
204
213
)
205
214
]
@@ -208,51 +217,51 @@ allTests = testGroup "ReverseDependenciesTest"
208
217
base4_15 = PackageIdentifier " base" (mkVersion [4 ,15 ])
209
218
base4_16 = PackageIdentifier " base" (mkVersion [4 ,16 ])
210
219
runWithPref preferences index pkg = runIdentity $
211
- dependencyReleaseEmails userSetIdForPackage index (constructReverseIndex index) preferences pkg
220
+ getUserNotificationsOnRelease userSetIdForPackage index (constructReverseIndex index) preferences pkg
212
221
runWithPrefAlsoMtl2 preferences index pkg = runIdentity $
213
- dependencyReleaseEmails userSet index (constructReverseIndex index) preferences pkg
222
+ getUserNotificationsOnRelease userSet index (constructReverseIndex index) preferences pkg
214
223
where
215
224
userSet arg | arg == mkPackageName " mtl" = Identity (UserIdSet. fromList [UserId 0 ])
216
225
| arg == mkPackageName " mtl2" = Identity (UserIdSet. fromList [UserId 0 ])
217
226
| otherwise = error " should only get user ids for mtl and mtl2"
218
227
assertEqual
219
- " dependencyReleaseEmails (trigger=NewIncompatibility) shouldn't generate a notification when there are packages, but none are behind"
228
+ " getUserNotificationsOnRelease (trigger=NewIncompatibility) shouldn't generate a notification when there are packages, but none are behind"
220
229
mempty
221
230
(runWithPref (pref NewIncompatibility ) (PackageIndex. fromList twoPackagesWithNoDepsOutOfRange) base4_14)
222
231
assertEqual
223
- " dependencyReleaseEmails (trigger=NewIncompatibility) should generate a notification when package is a single base version behind"
224
- (refNotification base4_15)
232
+ " getUserNotificationsOnRelease (trigger=NewIncompatibility) should generate a notification when package is a single base version behind"
233
+ userNotification
225
234
(runWithPref (pref NewIncompatibility ) (PackageIndex. fromList newBaseReleased) base4_15)
226
235
assertEqual
227
- " dependencyReleaseEmails (trigger=NewIncompatibility) should generate a notification for two packages that are a single base version behind"
236
+ " getUserNotificationsOnRelease (trigger=NewIncompatibility) should generate a notification for two packages that are a single base version behind"
228
237
(Just $
229
238
Set. fromList
230
239
[ PackageIdentifier (mkPackageName " mtl" ) (mkVersion [2 ,3 ])
231
240
, PackageIdentifier (mkPackageName " mtl2" ) (mkVersion [2 ,3 ])
232
241
]
233
242
)
234
243
( fmap Set. fromList
235
- . Map. lookup (UserId 0 , base4_15 )
244
+ . Map. lookup (UserId 0 )
236
245
$ runWithPrefAlsoMtl2 (pref NewIncompatibility ) (PackageIndex. fromList newBaseReleasedMultiple) base4_15
237
246
)
238
247
assertEqual
239
- " dependencyReleaseEmails (trigger=BoundsOutOfRange) should generate a notification when package is a single base version behind"
240
- (refNotification base4_15)
248
+ " getUserNotificationsOnRelease (trigger=BoundsOutOfRange) should generate a notification when package is a single base version behind"
249
+ userNotification
241
250
(runWithPref (pref BoundsOutOfRange ) (PackageIndex. fromList newBaseReleased) base4_15)
242
251
assertEqual
243
- " dependencyReleaseEmails (trigger=NewIncompatibility) shouldn't generate a notification when package is two base versions behind"
252
+ " getUserNotificationsOnRelease (trigger=NewIncompatibility) shouldn't generate a notification when package is two base versions behind"
244
253
mempty
245
254
(runWithPref (pref NewIncompatibility ) (PackageIndex. fromList twoNewBasesReleased) base4_16)
246
255
assertEqual
247
- " dependencyReleaseEmails (trigger=BoundsOutOfRange) should generate a notification when package is two base versions behind"
248
- (refNotification base4_16)
256
+ " getUserNotificationsOnRelease (trigger=BoundsOutOfRange) should generate a notification when package is two base versions behind"
257
+ userNotification
249
258
(runWithPref (pref BoundsOutOfRange ) (PackageIndex. fromList twoNewBasesReleased) base4_16)
250
259
assertEqual
251
- " dependencyReleaseEmails (trigger=BoundsOutOfRange) shouldn't generate a notification when the new package is for an old release series"
260
+ " getUserNotificationsOnRelease (trigger=BoundsOutOfRange) shouldn't generate a notification when the new package is for an old release series"
252
261
mempty
253
262
(runWithPref (pref BoundsOutOfRange ) (PackageIndex. fromList newVersionOfOldBase) base4_14_1)
254
263
assertEqual
255
- " dependencyReleaseEmails (trigger=BoundsOutOfRange) should only generate a notification when the new version is forbidden across all branches"
264
+ " getUserNotificationsOnRelease (trigger=BoundsOutOfRange) should only generate a notification when the new version is forbidden across all branches"
256
265
mempty -- The two branches below should get OR'd and therefore the dependency is not out of bounds
257
266
(runWithPref
258
267
(pref BoundsOutOfRange )
0 commit comments