Skip to content

Commit

Permalink
lots of stubbing to remove dependencies
Browse files Browse the repository at this point in the history
this removes dependencies on external services (stubbing of  http calls) as well as dependencies between tests
  • Loading branch information
cmurczek-it committed Feb 20, 2017
1 parent b3572a5 commit 6da0224
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 16 deletions.
5 changes: 5 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,8 @@ gulp.task('tslint', () => {
emitError: false
}))
});

gulp.task('testdata', () => {
gulp.src('./test/data/*.*')
.pipe(gulp.dest('./out/test/data'));
})
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"main": "./out/src/main",
"scripts": {
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -p ./ && gulp tslint",
"compile": "tsc -p ./ && gulp tslint && gulp testdata",
"watch": "tsc -watch -p ./",
"test": "node ./node_modules/vscode/bin/test",
"postinstall": "node ./node_modules/vscode/bin/install"
Expand All @@ -51,8 +51,11 @@
"@types/fs-extra": "0.0.35",
"@types/mkdirp": "^0.3.29",
"@types/mocha": "^2.2.32",
"@types/nock": "^8.2.1",
"@types/node": "^6.0.40",
"@types/semver": "^5.3.30",
"@types/sinon": "^1.16.35",
"@types/sinon-chai": "^2.7.27",
"@types/tmp": "0.0.32",
"@types/xml-parser": "^1.2.28",
"chai": "^3.5.0",
Expand All @@ -62,7 +65,10 @@
"gulp-mocha": "^2.1.3",
"gulp-tslint": "^4.3.0",
"mocha": "^2.3.3",
"nock": "^9.0.6",
"plist": "^2.0.1",
"sinon": "^1.17.7",
"sinon-chai": "^2.8.0",
"tslint": "^3.15.1",
"tslint-microsoft-contrib": "^2.0.12",
"typescript": "^2.0.3",
Expand Down
7 changes: 7 additions & 0 deletions src/nuget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export class NuGetClient{
}
resolve(servicesUpdated);
});
response.on('error', (err) => reject('Can\'t connect to package source due to ' + err.message));
});
}
});
Expand Down Expand Up @@ -172,6 +173,7 @@ export class NuGetClient{
let payload = JSON.parse(json);
res(payload.data);
});
response.on('error', (err) => rej('Can\'t query packages from ' + ps + ' due to' + err.message));
});
}));
});
Expand All @@ -184,6 +186,8 @@ export class NuGetClient{
}
});
resolve(packageIds);
}, (reasons) => {
debugger;
});
});
}
Expand Down Expand Up @@ -218,6 +222,7 @@ export class NuGetClient{
}
res(versions);
});
response.on('error', (err) => rej('Can\'t query versions from ' + ps + ' due to ' + err.message));
});
}));
});
Expand All @@ -230,6 +235,8 @@ export class NuGetClient{
}
});
resolve(versions);
}, reasons => {
debugger;
});
});
}
Expand Down
11 changes: 11 additions & 0 deletions test/data/AutoCompleteResponseNoId.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"@context":{
"@vocab":"http://schema.nuget.org/schema#"
},
"totalHits":67541,
"lastReopen":"2017-02-15T11:22:56.2233078Z",
"index":"v3-lucene0-v2v3-20170110",
"data":[
"Newtonsoft.Json","NUnit","EntityFramework","jQuery","bootstrap","AutoMapper","log4net","Microsoft.AspNet.Mvc","NUnit.Runners","angularjs"
]
}
11 changes: 11 additions & 0 deletions test/data/AutoCompleteResponsePartialId.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"@context":{
"@vocab":"http://schema.nuget.org/schema#"
},
"totalHits":40,
"lastReopen":"2017-02-15T11:14:37.0834689Z",
"index":"v3-lucene0-v2v3-20170110",
"data":[
"Newtonsoft.Json","Rebus.NewtonsoftJson","HybridDb.NewtonsoftJson","Newtonsoft.Msgpack","Newtonsoft.Json.FSharp","rethinkdb-net-newtonsoft","Rock.Core.Newtonsoft","Newtonsoft.Json.Schema","NewtonsoftJsonExt","Sfa.Core.Newtonsoft.Json","Newtonsoft.JsonResult","Newtonsoft.Json.Glimpse","Unity.Newtonsoft.Json","Newtonsoft.Dson","Pollock.Newtonsoft.Json","Newtonsoft.Json.Interface","Newtonsoft.Json.Net20.dll","Lime.Protocol.Serialization.Newtonsoft","Cronus.Serialization.NewtonsoftJson","Gu.Persist.NewtonsoftJson"
]
}
57 changes: 57 additions & 0 deletions test/data/FindVersionsResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"versions": [
"3.5.8",
"4.0.1",
"4.0.2",
"4.0.3",
"4.0.4",
"4.0.5",
"4.0.6",
"4.0.7",
"4.0.8",
"4.5.1",
"4.5.2",
"4.5.3",
"4.5.4",
"4.5.5",
"4.5.6",
"4.5.7",
"4.5.8",
"4.5.9",
"4.5.10",
"4.5.11",
"5.0.1",
"5.0.2",
"5.0.3",
"5.0.4",
"5.0.5",
"5.0.6",
"5.0.7",
"5.0.8",
"6.0.1-beta1",
"6.0.1",
"6.0.2",
"6.0.3",
"6.0.4",
"6.0.5",
"6.0.6",
"6.0.7",
"6.0.8",
"7.0.1-beta1",
"7.0.1-beta2",
"7.0.1-beta3",
"7.0.1",
"8.0.1-beta1",
"8.0.1-beta2",
"8.0.1-beta3",
"8.0.1-beta4",
"8.0.1",
"8.0.2",
"8.0.3",
"8.0.4-beta1",
"9.0.1-beta1",
"9.0.1",
"9.0.2-beta1",
"9.0.2-beta2"
]
}
3 changes: 3 additions & 0 deletions test/data/PackageNotFound.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.
RequestId:705260ad-0001-0037-18a0-87250b000000
Time:2017-02-15T15:33:42.4056251Z</Message></Error>
146 changes: 146 additions & 0 deletions test/data/PackageSourceIndex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"version": "3.0.0-beta.1",
"resources": [
{
"@id": "https://api-v2v3search-0.nuget.org/query",
"@type": "SearchQueryService",
"comment": "Query endpoint of NuGet Search service (primary)"
},
{
"@id": "https://api-v2v3search-1.nuget.org/query",
"@type": "SearchQueryService",
"comment": "Query endpoint of NuGet Search service (secondary)"
},
{
"@id": "https://api-v2v3search-0.nuget.org/autocomplete",
"@type": "SearchAutocompleteService",
"comment": "Autocomplete endpoint of NuGet Search service (primary)"
},
{
"@id": "https://api-v2v3search-1.nuget.org/autocomplete",
"@type": "SearchAutocompleteService",
"comment": "Autocomplete endpoint of NuGet Search service (secondary)"
},
{
"@id": "https://api-v2v3search-0.nuget.org/",
"@type": "SearchGalleryQueryService/3.0.0-rc",
"comment": "Azure Website based Search Service used by Gallery (primary)"
},
{
"@id": "https://api-v2v3search-1.nuget.org/",
"@type": "SearchGalleryQueryService/3.0.0-rc",
"comment": "Azure Website based Search Service used by Gallery (secondary)"
},
{
"@id": "https://api.nuget.org/v3/registration1/",
"@type": "RegistrationsBaseUrl",
"comment": "Base URL of Azure storage where NuGet package registration info is stored"
},
{
"@id": "https://api.nuget.org/v3-flatcontainer/",
"@type": "PackageBaseAddress/3.0.0",
"comment": "Base URL of Azure storage where NuGet package registration info for NET Core is stored, in the format https://api.nuget.org/v3-flatcontainer/{id-lower}/{version-lower}.{version-lower}.nupkg"
},
{
"@id": "https://www.nuget.org/api/v2",
"@type": "LegacyGallery"
},
{
"@id": "https://www.nuget.org/api/v2",
"@type": "LegacyGallery/2.0.0"
},
{
"@id": "https://www.nuget.org/api/v2/package",
"@type": "PackagePublish/2.0.0"
},
{
"@id": "https://api-v2v3search-0.nuget.org/query",
"@type": "SearchQueryService/3.0.0-rc",
"comment": "Query endpoint of NuGet Search service (primary) used by RC clients"
},
{
"@id": "https://api-v2v3search-1.nuget.org/query",
"@type": "SearchQueryService/3.0.0-rc",
"comment": "Query endpoint of NuGet Search service (secondary) used by RC clients"
},
{
"@id": "https://api-v2v3search-0.nuget.org/autocomplete",
"@type": "SearchAutocompleteService/3.0.0-rc",
"comment": "Autocomplete endpoint of NuGet Search service (primary) used by RC clients"
},
{
"@id": "https://api-v2v3search-1.nuget.org/autocomplete",
"@type": "SearchAutocompleteService/3.0.0-rc",
"comment": "Autocomplete endpoint of NuGet Search service (secondary) used by RC clients"
},
{
"@id": "https://api.nuget.org/v3/registration1/",
"@type": "RegistrationsBaseUrl/3.0.0-rc",
"comment": "Base URL of Azure storage where NuGet package registration info is stored used by RC clients"
},
{
"@id": "https://www.nuget.org/packages/{id}/{version}/ReportAbuse",
"@type": "ReportAbuseUriTemplate/3.0.0-rc",
"comment": "URI template used by NuGet Client to construct Report Abuse URL for packages used by RC clients"
},
{
"@id": "https://api.nuget.org/v3/registration1/{id-lower}/index.json",
"@type": "PackageDisplayMetadataUriTemplate/3.0.0-rc",
"comment": "URI template used by NuGet Client to construct display metadata for Packages using ID"
},
{
"@id": "https://api.nuget.org/v3/registration1/{id-lower}/{version-lower}.json",
"@type": "PackageVersionDisplayMetadataUriTemplate/3.0.0-rc",
"comment": "URI template used by NuGet Client to construct display metadata for Packages using ID, Version"
},
{
"@id": "https://api-v2v3search-0.nuget.org/query",
"@type": "SearchQueryService/3.0.0-beta",
"comment": "Query endpoint of NuGet Search service (primary) used by beta clients"
},
{
"@id": "https://api-v2v3search-1.nuget.org/query",
"@type": "SearchQueryService/3.0.0-beta",
"comment": "Query endpoint of NuGet Search service (secondary) used by beta clients"
},
{
"@id": "https://api-v2v3search-0.nuget.org/autocomplete",
"@type": "SearchAutocompleteService/3.0.0-beta",
"comment": "Autocomplete endpoint of NuGet Search service (primary) used by beta clients"
},
{
"@id": "https://api-v2v3search-1.nuget.org/autocomplete",
"@type": "SearchAutocompleteService/3.0.0-beta",
"comment": "Autocomplete endpoint of NuGet Search service (secondary) used by beta clients"
},
{
"@id": "https://api.nuget.org/v3/registration1/",
"@type": "RegistrationsBaseUrl/3.0.0-beta",
"comment": "Base URL of Azure storage where NuGet package registration info is stored used by Beta clients"
},
{
"@id": "https://www.nuget.org/packages/{id}/{version}/ReportAbuse",
"@type": "ReportAbuseUriTemplate/3.0.0-beta",
"comment": "URI template used by NuGet Client to construct Report Abuse URL for packages"
},
{
"@id": "https://api.nuget.org/v3/stats0/totals.json",
"@type": "TotalStats/3.0.0-rc",
"comment": "Endpoint to get stats totals to display in nuget.org home page"
},
{
"@id": "https://api.nuget.org/v3/registration1-gz/",
"@type": "RegistrationsBaseUrl/3.4.0",
"comment": "Base URL of Azure storage where NuGet package registration info is stored in GZIP format."
},
{
"@id": "https://api.nuget.org/v3/catalog0/index.json",
"@type": "Catalog/3.0.0",
"comment": "Index of the NuGet package catalog."
}
],
"@context": {
"@vocab": "http://schema.nuget.org/services#",
"comment": "http://www.w3.org/2000/01/rdf-schema#comment"
}
}
Loading

0 comments on commit 6da0224

Please sign in to comment.