Skip to content

Commit

Permalink
test: fix the macroscope failure test
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanCacqueray committed Dec 21, 2023
1 parent 2475a4e commit 5cac8e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Lentille.hs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ type Changes = (Change, [ChangeEvent])
-- We don't care about the rest so we replace it with ()
-- See: https://hackage.haskell.org/package/streaming-0.2.4.0/docs/Streaming-Prelude.html#v:break
--
-- >>> let stream = S.yield (Left (DecodeError ["oops"]))
-- >>> let stream = S.yield (Left (DecodeError [utctime|2021-05-31 00:00:00|] ["oops"]))
-- >>> runEff $ S.length_ $ streamDropBefore [utctime|2021-05-31 00:00:00|] stream
-- 1
streamDropBefore :: UTCTime -> LentilleStream es Changes -> LentilleStream es Changes
Expand Down
10 changes: 6 additions & 4 deletions src/Macroscope/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ testCrawlingPoint = do
Macroscope.runStream apiKey indexName (CrawlerName crawlerName) (Macroscope.Changes badStream)

(currentOldestAge, _) <- getOldest
liftIO $ assertEqual "Commit date is not updated on failure" oldestAge currentOldestAge
liftIO $ assertBool "Commit date is updated on failure" (currentOldestAge > oldestAge)

Macroscope.runStream apiKey indexName (CrawlerName crawlerName) (Macroscope.Changes goodStream)
-- TODO: check that the errors got indexed

Macroscope.runStream apiKey indexName (CrawlerName crawlerName) (Macroscope.Changes $ goodStream currentOldestAge)

(newOldestAge, _) <- getOldest
liftIO $ assertBool "Commit date updated" (newOldestAge > oldestAge)
Expand All @@ -68,8 +70,8 @@ testCrawlingPoint = do
| otherwise = error "Bad crawling point"

-- A document stream that yield a change
goodStream date name
| date == BT.fakeDateAlt && name == "opendev/neutron" = do
goodStream expected date name
| date == expected && name == "opendev/neutron" = do
Streaming.yield $ Right (fakeChangePB, [])
| otherwise = error "Bad crawling point"

Expand Down
4 changes: 2 additions & 2 deletions src/Macroscope/Worker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ processStream logFunc postFunc = go (0 :: Word) [] []
Right (edoc, rest) -> do
-- We got a new document
let doc = case edoc of
Right x -> x
Left err -> DTError $ from err
Right x -> x
Left err -> DTError $ from err
let newAcc = doc : acc
if count == 499
then do
Expand Down

0 comments on commit 5cac8e3

Please sign in to comment.