@@ -9,16 +9,16 @@ const Request = require('../../../../ghcrawler').request
99const fs = require ( 'fs' )
1010const { merge } = require ( 'lodash' )
1111
12- const stub = 'https://proxy.golang.org/'
12+ const goBaseURL = 'https://proxy.golang.org/'
1313
1414describe ( 'Go utility functions' , ( ) => {
1515 it ( 'builds URLs' , ( ) => {
1616 const fetch = GoFetch ( { } )
17- expect ( fetch . _buildUrl ( spec ( 'go' , 'golang' , 'cloud.google.com' , 'go' , 'v0.56.0' ) ) ) . to . equal ( stub + 'cloud.google.com/go/@v/v0.56.0.zip' )
18- expect ( fetch . _buildUrl ( spec ( 'go' , 'golang' , 'cloud.google.com' , 'go' , 'v0.56.0' ) , '.mod' ) ) . to . equal ( stub + 'cloud.google.com/go/@v/v0.56.0.mod' )
19- expect ( fetch . _buildUrl ( spec ( 'go' , 'golang' , '-' , 'collectd.org' , 'v0.5.0' ) ) ) . to . equal ( stub + 'collectd.org/@v/v0.5.0.zip' )
20- expect ( fetch . _buildUrl ( spec ( 'go' , 'golang' , 'github.com%2fAzure%2fazure-event-hubs-go' , 'v3' , 'v3.2.0' ) ) ) . to . equal ( stub + 'github.com/Azure/azure-event-hubs-go/v3/@v/v3.2.0.zip' )
21- expect ( fetch . _buildUrl ( spec ( 'go' , 'golang' , 'github.com%2FAzure%2Fazure-event-hubs-go' , 'v3' , 'v3.2.0' ) ) ) . to . equal ( stub + 'github.com/Azure/azure-event-hubs-go/v3/@v/v3.2.0.zip' )
17+ expect ( fetch . _buildUrl ( spec ( 'go' , 'golang' , 'cloud.google.com' , 'go' , 'v0.56.0' ) ) ) . to . equal ( goBaseURL + 'cloud.google.com/go/@v/v0.56.0.zip' )
18+ expect ( fetch . _buildUrl ( spec ( 'go' , 'golang' , 'cloud.google.com' , 'go' , 'v0.56.0' ) , '.mod' ) ) . to . equal ( goBaseURL + 'cloud.google.com/go/@v/v0.56.0.mod' )
19+ expect ( fetch . _buildUrl ( spec ( 'go' , 'golang' , '-' , 'collectd.org' , 'v0.5.0' ) ) ) . to . equal ( goBaseURL + 'collectd.org/@v/v0.5.0.zip' )
20+ expect ( fetch . _buildUrl ( spec ( 'go' , 'golang' , 'github.com%2fAzure%2fazure-event-hubs-go' , 'v3' , 'v3.2.0' ) ) ) . to . equal ( goBaseURL + 'github.com/Azure/azure-event-hubs-go/v3/@v/v3.2.0.zip' )
21+ expect ( fetch . _buildUrl ( spec ( 'go' , 'golang' , 'github.com%2FAzure%2Fazure-event-hubs-go' , 'v3' , 'v3.2.0' ) ) ) . to . equal ( goBaseURL + 'github.com/Azure/azure-event-hubs-go/v3/@v/v3.2.0.zip' )
2222 } )
2323} )
2424
@@ -47,6 +47,7 @@ describe('Go Proxy fetching', () => {
4747 beforeEach ( ( ) => {
4848 const requestPromiseStub = options => {
4949 if ( options . url ) {
50+ expect ( options . url ) . to . contain ( goBaseURL )
5051 if ( options . url . includes ( 'error' ) ) throw new Error ( 'yikes' )
5152 if ( options . url . includes ( 'code' ) ) throw { statusCode : 500 , message : 'Code' }
5253 if ( options . url . includes ( 'missing' ) ) throw { statusCode : 404 }
0 commit comments