@@ -13,11 +13,22 @@ const resolvedMavenUrl = "http://reallygoodurl.mvn"
1313const { generateMavenInfo } = require ( "./src/maven/maven-info" )
1414jest . mock ( "./src/maven/maven-info" )
1515
16+ const dataCatRelocation = {
17+ artifactId : "quarkus-micrometer-registry-datadog" ,
18+ groupId : "io.quarkiverse.micrometer.registry"
19+ }
20+
1621generateMavenInfo . mockImplementation ( artifactId => {
1722 const coordinates = parse ( artifactId )
1823 // This is totally unscientific and arbitrary, but it's reproducible
1924 coordinates . timestamp = artifactId . length
2025 coordinates . url = resolvedMavenUrl
26+
27+ // Special case the datacat artifact by doing some hardcoding
28+ if ( artifactId . includes ( "datacat" ) ) {
29+ coordinates . relocation = dataCatRelocation
30+ }
31+
2132 return coordinates
2233} )
2334
@@ -433,7 +444,7 @@ describe("the main gatsby entrypoint", () => {
433444 } )
434445 } )
435446
436- describe ( "for an extension with an other extension sharing the artifact id " , ( ) => {
447+ describe ( "for an extension with a relocation to another extension " , ( ) => {
437448 const extension = {
438449 artifact :
439450 "io.quarkiverse.micrometer.registry:quarkus-micrometer-registry-datadog::jar:2.12.0" ,
@@ -443,10 +454,10 @@ describe("the main gatsby entrypoint", () => {
443454 }
444455 const olderExtension = {
445456 artifact :
446- "io.quarkelsewhere:quarkus-micrometer-registry-datadog ::jar:3.12.0" ,
457+ "io.quarkelsewhere:quarkus-micrometer-registry-datacat ::jar:3.12.0" ,
447458 origins : [
448459 "io.quarkus.platform:quarkus-bom-quarkus-platform-descriptor:3.0.0.Alpha3:json:3.0.0.Alpha3" ,
449- ] ,
460+ ]
450461 }
451462
452463 // A cut down version of what the registry returns us, with just the relevant bits
@@ -473,27 +484,28 @@ describe("the main gatsby entrypoint", () => {
473484 expect ( createNodeId ) . toHaveBeenCalledTimes ( 2 )
474485 } )
475486
476- it ( "adds a link to the older extension from the new one" , ( ) => {
487+ it ( "adds a link to the newer extension from the older one" , ( ) => {
477488 expect ( createNode ) . toHaveBeenCalledWith (
478489 expect . objectContaining ( {
479490 artifact : extension . artifact ,
480491 duplicates : [
481492 expect . objectContaining ( {
482493 groupId : "io.quarkelsewhere" ,
483- slug : "io.quarkelsewhere/quarkus-micrometer-registry-datadog " ,
494+ slug : "io.quarkelsewhere/quarkus-micrometer-registry-datacat " ,
484495 } ) ,
485496 ] ,
486497 } )
487498 )
488499 } )
489500
490- it ( "adds a link to the newer extension from the old one" , ( ) => {
501+ it ( "adds a link to the older extension from the new one" , ( ) => {
491502 expect ( createNode ) . toHaveBeenCalledWith (
492503 expect . objectContaining ( {
493504 artifact : olderExtension . artifact ,
494505 duplicates : [
495506 expect . objectContaining ( {
496507 groupId : "io.quarkiverse.micrometer.registry" ,
508+ slug : "io.quarkiverse.micrometer.registry/quarkus-micrometer-registry-datadog" ,
497509 } ) ,
498510 ] ,
499511 } )
@@ -507,7 +519,20 @@ describe("the main gatsby entrypoint", () => {
507519 duplicates : [
508520 expect . objectContaining ( {
509521 relationship : "older" ,
510- timestamp : 65 ,
522+ } ) ,
523+ ] ,
524+ } )
525+ )
526+ } )
527+
528+ it ( "adds data to the older one explaining what is different" , ( ) => {
529+ expect ( createNode ) . toHaveBeenCalledWith (
530+ expect . objectContaining ( {
531+ artifact : extension . artifact ,
532+ duplicates : [
533+ expect . objectContaining ( {
534+ differenceReason : "artifact id" ,
535+ differentId : "quarkus-micrometer-registry-datacat"
511536 } ) ,
512537 ] ,
513538 } )
@@ -521,7 +546,20 @@ describe("the main gatsby entrypoint", () => {
521546 duplicates : [
522547 expect . objectContaining ( {
523548 relationship : "newer" ,
524- timestamp : 82 ,
549+ } ) ,
550+ ] ,
551+ } )
552+ )
553+ } )
554+
555+ it ( "adds data to the newer one explaining what is different" , ( ) => {
556+ expect ( createNode ) . toHaveBeenCalledWith (
557+ expect . objectContaining ( {
558+ artifact : olderExtension . artifact ,
559+ duplicates : [
560+ expect . objectContaining ( {
561+ differenceReason : "artifact id" ,
562+ differentId : "quarkus-micrometer-registry-datadog"
525563 } ) ,
526564 ] ,
527565 } )
@@ -545,100 +583,5 @@ describe("the main gatsby entrypoint", () => {
545583 } )
546584 )
547585 } )
548-
549- describe ( "when maven conks out and does not give a timestamp" , ( ) => {
550- beforeAll ( async ( ) => {
551- // Clear any history from the parent beforeAll()
552- jest . clearAllMocks ( )
553-
554- generateMavenInfo . mockImplementation ( artifactId => {
555- const coordinates = parse ( artifactId )
556- // This is totally unscientific and arbitrary, but it's reproducible
557- coordinates . timestamp = undefined
558- coordinates . url = resolvedMavenUrl
559- return coordinates
560- } )
561-
562- axios . get = jest . fn ( ) . mockReturnValue ( {
563- data : {
564- extensions : [ extension , olderExtension ] ,
565- platforms : currentPlatforms . platforms ,
566- } ,
567- } )
568-
569- await sourceNodes ( { actions, createNodeId, createContentDigest } )
570- } )
571-
572- it ( "adds a link to the older extension from the new one" , ( ) => {
573- expect ( createNode ) . toHaveBeenCalledWith (
574- expect . objectContaining ( {
575- artifact : extension . artifact ,
576- duplicates : [
577- expect . objectContaining ( {
578- groupId : "io.quarkelsewhere" ,
579- slug : "io.quarkelsewhere/quarkus-micrometer-registry-datadog" ,
580- } ) ,
581- ] ,
582- } )
583- )
584- } )
585-
586- it ( "does not mark the new extension as superseded" , ( ) => {
587- expect ( createNode ) . not . toHaveBeenCalledWith (
588- expect . objectContaining ( {
589- artifact : extension . artifact ,
590- isSuperseded : true ,
591- } )
592- )
593- } )
594-
595- it ( "adds a link to the newer extension from the old one" , ( ) => {
596- expect ( createNode ) . toHaveBeenCalledWith (
597- expect . objectContaining ( {
598- artifact : olderExtension . artifact ,
599- duplicates : [
600- expect . objectContaining ( {
601- groupId : "io.quarkiverse.micrometer.registry" ,
602- } ) ,
603- ] ,
604- } )
605- )
606- } )
607-
608- it ( "does not mark the older extension as superseded" , ( ) => {
609- expect ( createNode ) . not . toHaveBeenCalledWith (
610- expect . objectContaining ( {
611- artifact : olderExtension . artifact ,
612- isSuperseded : true ,
613- } )
614- )
615- } )
616-
617- it ( "marks the older duplicate as just different" , ( ) => {
618- expect ( createNode ) . toHaveBeenCalledWith (
619- expect . objectContaining ( {
620- artifact : extension . artifact ,
621- duplicates : [
622- expect . objectContaining ( {
623- relationship : "different" ,
624- } ) ,
625- ] ,
626- } )
627- )
628- } )
629-
630- it ( "marks the newer duplicate as just different" , ( ) => {
631- expect ( createNode ) . toHaveBeenCalledWith (
632- expect . objectContaining ( {
633- artifact : olderExtension . artifact ,
634- duplicates : [
635- expect . objectContaining ( {
636- relationship : "different" ,
637- } ) ,
638- ] ,
639- } )
640- )
641- } )
642- } )
643586 } )
644587} )
0 commit comments