@@ -189,25 +189,25 @@ class TopicLoaderIntSpec extends KafkaSpecBase[IO] {
189189
190190      val  (preLoad, postLoad) =  records(1  to 15 ).splitAt(10 )
191191
192-       val  loadRef :  IO [Ref [IO , Boolean ]]                =  Ref .of(false )
193-       val  topicRef :  IO [Ref [IO , Seq [(String , String )]]] =  Ref .empty
194- 
195192      for  {
196-         loadState  <-  loadRef 
197-         topicState <-  topicRef 
193+         loadState  <-  Ref .of[ IO ,  Boolean ]( false ) 
194+         topicState <-  Ref .empty[ IO ,  Seq [( String ,  String )]] 
198195        _          <-  createCustomTopics(NonEmptyList .one(testTopic1))
199196        _          <-  publishStringMessages(testTopic1, preLoad)
200-         fiber      <-  loadAndRunLoader(NonEmptyList .one(testTopic1))(_ =>  loadState.set(true ))
201-                         .map(recordToTuple)
202-                         .evalTap(r =>  topicState.getAndUpdate(_ :+  r))
203-                         .compile
204-                         .drain
205-                         .start
206-         _          <-  eventually(topicState.get.asserting(_ should contain theSameElementsAs preLoad))
207-         _          <-  loadState.get.asserting(_ shouldBe true )
208-         _          <-  publishStringMessages(testTopic1, postLoad)
209-         assertion  <-  eventually(topicState.get.asserting(_ should contain theSameElementsAs (preLoad ++  postLoad)))
210-         _          <-  fiber.cancel
197+         assertion  <-  loadAndRunR(NonEmptyList .one(testTopic1))(
198+                         _ =>  loadState.set(true ),
199+                         r =>  topicState.getAndUpdate(_ :+  r).void
200+                       ).use { _ => 
201+                         for  {
202+                           _         <-  eventually(topicState.get.asserting(_ should contain theSameElementsAs preLoad))
203+                           _         <-  loadState.get.asserting(_ shouldBe true )
204+                           _         <-  publishStringMessages(testTopic1, postLoad)
205+                           assertion <- 
206+                             eventually(
207+                               topicState.get.asserting(_ should contain theSameElementsAs (preLoad ++  postLoad))
208+                             )
209+                         } yield  assertion
210+                       }
211211      } yield  assertion
212212    }
213213
0 commit comments