@@ -23,6 +23,7 @@ import scala.concurrent.duration._
23
23
24
24
// Cats
25
25
import cats .Id
26
+ import cats .data .NonEmptyList
26
27
import cats .effect .IO
27
28
import cats .effect .implicits ._
28
29
import cats .implicits ._
@@ -228,16 +229,13 @@ class ResolverResultSpec extends Specification with ValidatedMatchers with CatsE
228
229
val time = Instant .ofEpochMilli(3L )
229
230
val responses = List (timeoutError, correctResult)
230
231
231
- val httpRep =
232
- Registry .Http (Registry .Config (" Mock Repo" , 1 , List (" com.snowplowanalytics.iglu-test" )), null )
233
-
234
232
implicit val cache = ResolverSpecHelpers .staticResolverCache
235
233
implicit val clock = ResolverSpecHelpers .staticClock
236
234
implicit val registryLookup : RegistryLookup [StaticLookup ] =
237
235
ResolverSpecHelpers .getLookup(responses, Nil )
238
236
239
237
val result = for {
240
- resolver <- Resolver .init[StaticLookup ](10 , None , httpRep)
238
+ resolver <- Resolver .init[StaticLookup ](10 , None , Repos . httpRep)
241
239
response1 <- resolver.lookupSchemaResult(schemaKey)
242
240
response2 <- resolver.lookupSchemaResult(schemaKey)
243
241
_ <- StaticLookup .addTime(600 .milliseconds)
@@ -284,9 +282,6 @@ class ResolverResultSpec extends Specification with ValidatedMatchers with CatsE
284
282
RegistryError .RepoFailure (" Should never be reached" ).asLeft
285
283
)
286
284
287
- val httpRep =
288
- Registry .Http (Registry .Config (" Mock Repo" , 1 , List (" com.snowplowanalytics.iglu-test" )), null )
289
-
290
285
implicit val cache = ResolverSpecHelpers .staticResolverCache
291
286
implicit val clock = ResolverSpecHelpers .staticClock
292
287
implicit val registryLookup : RegistryLookup [StaticLookup ] =
@@ -298,7 +293,7 @@ class ResolverResultSpec extends Specification with ValidatedMatchers with CatsE
298
293
.init[StaticLookup ](
299
294
10 ,
300
295
Some (1 .seconds),
301
- httpRep
296
+ Repos . httpRep
302
297
)
303
298
_ <- resolver.lookupSchemaResult(schemaKey)
304
299
_ <- StaticLookup .addTime(2 .seconds)
@@ -337,14 +332,8 @@ class ResolverResultSpec extends Specification with ValidatedMatchers with CatsE
337
332
val error4 = RegistryError .RepoFailure (" Server segfault" )
338
333
339
334
// Mocking repositories
340
- val httpRep1 = Registry .Http (
341
- Registry .Config (" Mock Repo 1" , 1 , List (" com.snowplowanalytics.iglu-test" )),
342
- null
343
- )
344
- val httpRep2 = Registry .Http (
345
- Registry .Config (" Mock Repo 2" , 1 , List (" com.snowplowanalytics.iglu-test" )),
346
- null
347
- )
335
+ val httpRep1 = Repos .httpRep.copy(config = Repos .httpRep.config.copy(name = " Mock Repo 1" ))
336
+ val httpRep2 = Repos .httpRep.copy(config = Repos .httpRep.config.copy(name = " Mock Repo 2" ))
348
337
349
338
implicit val cache = ResolverSpecHelpers .staticResolverCache
350
339
implicit val clock = ResolverSpecHelpers .staticClock
@@ -479,16 +468,13 @@ class ResolverResultSpec extends Specification with ValidatedMatchers with CatsE
479
468
Json .Null .asRight[RegistryError ]
480
469
val responses = List (schema, schema)
481
470
482
- val httpRep =
483
- Registry .Http (Registry .Config (" Mock Repo" , 1 , List (" com.snowplowanalytics.iglu-test" )), null )
484
-
485
471
implicit val cache = ResolverSpecHelpers .staticResolverCache
486
472
implicit val clock = ResolverSpecHelpers .staticClock
487
473
implicit val registryLookup : RegistryLookup [StaticLookup ] =
488
474
ResolverSpecHelpers .getLookup(responses, Nil )
489
475
490
476
val result = for {
491
- resolver <- Resolver .init[StaticLookup ](10 , Some (200 .seconds), httpRep)
477
+ resolver <- Resolver .init[StaticLookup ](10 , Some (200 .seconds), Repos . httpRep)
492
478
response1 <- resolver.lookupSchemaResult(schemaKey)
493
479
_ <- StaticLookup .addTime(150 .seconds) // ttl 200, delay 150
494
480
response2 <- resolver.lookupSchemaResult(schemaKey)
@@ -517,16 +503,13 @@ class ResolverResultSpec extends Specification with ValidatedMatchers with CatsE
517
503
Json .Null .asRight[RegistryError ]
518
504
val responses = List (schema, schema)
519
505
520
- val httpRep =
521
- Registry .Http (Registry .Config (" Mock Repo" , 1 , List (" com.snowplowanalytics.iglu-test" )), null )
522
-
523
506
implicit val cache = ResolverSpecHelpers .staticResolverCache
524
507
implicit val clock = ResolverSpecHelpers .staticClock
525
508
implicit val registryLookup : RegistryLookup [StaticLookup ] =
526
509
ResolverSpecHelpers .getLookup(responses, Nil )
527
510
528
511
val result = for {
529
- resolver <- Resolver .init[StaticLookup ](10 , Some (200 .seconds), httpRep)
512
+ resolver <- Resolver .init[StaticLookup ](10 , Some (200 .seconds), Repos . httpRep)
530
513
response1 <- resolver.lookupSchemaResult(schemaKey)
531
514
_ <- StaticLookup .addTime(250 .seconds) // ttl 200, delay 250
532
515
response2 <- resolver.lookupSchemaResult(schemaKey)
@@ -668,16 +651,13 @@ class ResolverResultSpec extends Specification with ValidatedMatchers with CatsE
668
651
val notFound = RegistryError .NotFound .asLeft[Json ]
669
652
val responses = List (notFound, schema)
670
653
671
- val httpRep =
672
- Registry .Http (Registry .Config (" Mock Repo" , 1 , List (" com.snowplowanalytics.iglu-test" )), null )
673
-
674
654
implicit val cache = ResolverSpecHelpers .staticResolverCache
675
655
implicit val clock = ResolverSpecHelpers .staticClock
676
656
implicit val registryLookup : RegistryLookup [StaticLookup ] =
677
657
ResolverSpecHelpers .getLookup(responses, Nil )
678
658
679
659
val result = for {
680
- resolver <- Resolver .init[StaticLookup ](10 , Some (200 .seconds), httpRep)
660
+ resolver <- Resolver .init[StaticLookup ](10 , Some (200 .seconds), Repos . httpRep)
681
661
response1 <- resolver.lookupSchemaResult(schemaKey)
682
662
_ <- StaticLookup .addTime(150 .seconds) // ttl 200, delay 150
683
663
response2 <- resolver.lookupSchemaResult(schemaKey)
@@ -719,17 +699,15 @@ class ResolverResultSpec extends Specification with ValidatedMatchers with CatsE
719
699
val notFound = RegistryError .NotFound .asLeft[Json ]
720
700
val responses = List (notFound, notFound, schema)
721
701
722
- val repoName = " Mock Repo"
723
- val httpRep =
724
- Registry .Http (Registry .Config (repoName, 1 , List (" com.snowplowanalytics.iglu-test" )), null )
702
+ val repoName = Repos .httpRep.config.name
725
703
726
704
implicit val cache = ResolverSpecHelpers .staticResolverCache
727
705
implicit val clock = ResolverSpecHelpers .staticClock
728
706
implicit val registryLookup : RegistryLookup [StaticLookup ] =
729
707
ResolverSpecHelpers .getLookup(responses, Nil )
730
708
731
709
val result = for {
732
- resolver <- Resolver .init[StaticLookup ](10 , Some (200 .seconds), httpRep)
710
+ resolver <- Resolver .init[StaticLookup ](10 , Some (200 .seconds), Repos . httpRep)
733
711
response1 <- resolver.lookupSchemaResult(schemaKey)
734
712
_ <- StaticLookup .addTime(250 .seconds) // ttl 200, delay 250
735
713
response2 <- resolver.lookupSchemaResult(schemaKey)
@@ -765,45 +743,45 @@ class ResolverResultSpec extends Specification with ValidatedMatchers with CatsE
765
743
766
744
import ResolverSpecHelpers .LookupSchemasUntil ._
767
745
768
- def testLookupUntil (maxSchemaKey : SchemaKey , expected : List [SelfDescribingSchema [Json ]]) =
746
+ def testLookupUntil (maxSchemaKey : SchemaKey , expected : NonEmptyList [SelfDescribingSchema [Json ]]) =
769
747
for {
770
748
resolver <- mkResolver
771
749
result <- resolver.lookupSchemasUntil(maxSchemaKey)
772
750
} yield result must beRight.like { case schemas => schemas must beEqualTo(expected) }
773
751
774
752
def e20 = testLookupUntil(
775
753
getUntilSchemaKey(1 , 0 , 0 ),
776
- List (until100)
754
+ NonEmptyList .one (until100)
777
755
)
778
756
779
757
def e21 = testLookupUntil(
780
758
getUntilSchemaKey(1 , 1 , 0 ),
781
- List (until100, until110)
759
+ NonEmptyList .of (until100, until110)
782
760
)
783
761
784
762
def e22 = testLookupUntil(
785
763
getUntilSchemaKey(1 , 1 , 1 ),
786
- List (until100, until110, until111)
764
+ NonEmptyList .of (until100, until110, until111)
787
765
)
788
766
789
767
def e23 = testLookupUntil(
790
768
getUntilSchemaKey(1 , 1 , 2 ),
791
- List (until100, until110, until111, until112)
769
+ NonEmptyList .of (until100, until110, until111, until112)
792
770
)
793
771
794
772
def e24 = testLookupUntil(
795
773
getUntilSchemaKey(1 , 2 , 0 ),
796
- List (until100, until110, until111, until112, until120)
774
+ NonEmptyList .of (until100, until110, until111, until112, until120)
797
775
)
798
776
799
777
def e25 = testLookupUntil(
800
778
getUntilSchemaKey(1 , 2 , 1 ),
801
- List (until100, until110, until111, until112, until120, until121)
779
+ NonEmptyList .of (until100, until110, until111, until112, until120, until121)
802
780
)
803
781
804
782
def e26 = testLookupUntil(
805
783
getUntilSchemaKey(1 , 2 , 2 ),
806
- List (until100, until110, until111, until112, until120, until121, until122)
784
+ NonEmptyList .of (until100, until110, until111, until112, until120, until121, until122)
807
785
)
808
786
809
787
def e27 = for {
@@ -836,11 +814,11 @@ class ResolverResultSpec extends Specification with ValidatedMatchers with CatsE
836
814
837
815
def e31 = testLookupUntil(
838
816
getUntilSchemaKey(3 , 0 , 0 ),
839
- List (until300)
817
+ NonEmptyList .one (until300)
840
818
)
841
819
842
820
def e32 = testLookupUntil(
843
821
getUntilSchemaKey(3 , 1 , 0 ),
844
- List (until300, until310)
822
+ NonEmptyList .of (until300, until310)
845
823
)
846
824
}
0 commit comments