@@ -748,7 +748,7 @@ test('retry on non-200', async () => {
748748 ` ) ;
749749} ) ;
750750
751- test ( 'constructs URL with usage.target' , async ( { expect } ) => {
751+ test ( 'constructs URL with usage.target (hvo1/) ' , async ( { expect } ) => {
752752 const logger = createHiveTestingLogger ( ) ;
753753 const token = 'hvo1/brrrrt' ;
754754 const dUrl = Promise . withResolvers < string > ( ) ;
@@ -793,3 +793,95 @@ test('constructs URL with usage.target', async ({ expect }) => {
793793 expect ( url ) . toEqual ( 'http://localhost/the-guild/graphql-hive/staging' ) ;
794794 await hive . dispose ( ) ;
795795} ) ;
796+
797+ test ( 'constructs URL with usage.target (hvp1/)' , async ( { expect } ) => {
798+ const logger = createHiveTestingLogger ( ) ;
799+ const token = 'hvp1/brrrrt' ;
800+ const dUrl = Promise . withResolvers < string > ( ) ;
801+
802+ const hive = createHive ( {
803+ enabled : true ,
804+ debug : true ,
805+ agent : {
806+ timeout : 500 ,
807+ maxRetries : 0 ,
808+ sendInterval : 1 ,
809+ maxSize : 1 ,
810+ async fetch ( url ) {
811+ dUrl . resolve ( url . toString ( ) ) ;
812+ return new Response ( '' , {
813+ status : 200 ,
814+ } ) ;
815+ } ,
816+ logger,
817+ } ,
818+ token,
819+ selfHosting : {
820+ graphqlEndpoint : 'http://localhost:2/graphql' ,
821+ applicationUrl : 'http://localhost:1' ,
822+ usageEndpoint : 'http://localhost' ,
823+ } ,
824+ usage : {
825+ target : 'the-guild/graphql-hive/staging' ,
826+ } ,
827+ } ) ;
828+
829+ await hive . collectUsage ( ) (
830+ {
831+ schema,
832+ document : op ,
833+ operationName : 'asd' ,
834+ } ,
835+ { } ,
836+ ) ;
837+
838+ const url = await dUrl . promise ;
839+ expect ( url ) . toEqual ( 'http://localhost/the-guild/graphql-hive/staging' ) ;
840+ await hive . dispose ( ) ;
841+ } ) ;
842+
843+ test ( 'constructs URL with usage.target (hvu1/)' , async ( { expect } ) => {
844+ const logger = createHiveTestingLogger ( ) ;
845+ const token = 'hvu1/brrrrt' ;
846+ const dUrl = Promise . withResolvers < string > ( ) ;
847+
848+ const hive = createHive ( {
849+ enabled : true ,
850+ debug : true ,
851+ agent : {
852+ timeout : 500 ,
853+ maxRetries : 0 ,
854+ sendInterval : 1 ,
855+ maxSize : 1 ,
856+ async fetch ( url ) {
857+ dUrl . resolve ( url . toString ( ) ) ;
858+ return new Response ( '' , {
859+ status : 200 ,
860+ } ) ;
861+ } ,
862+ logger,
863+ } ,
864+ token,
865+ selfHosting : {
866+ graphqlEndpoint : 'http://localhost:2/graphql' ,
867+ applicationUrl : 'http://localhost:1' ,
868+ usageEndpoint : 'http://localhost' ,
869+ } ,
870+ usage : {
871+ target : 'the-guild/graphql-hive/staging' ,
872+ } ,
873+ } ) ;
874+
875+ await hive . collectUsage ( ) (
876+ {
877+ schema,
878+ document : op ,
879+ operationName : 'asd' ,
880+ } ,
881+ { } ,
882+ ) ;
883+
884+ const url = await dUrl . promise ;
885+ expect ( url ) . toEqual ( 'http://localhost/the-guild/graphql-hive/staging' ) ;
886+ await hive . dispose ( ) ;
887+ } ) ;
0 commit comments