This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding additional unit tests and new integration tests (#47)
* Add additional unit tests (gitcontext, userinfo) * Adding integration tests
- Loading branch information
Jeff Young
committed
Sep 9, 2016
1 parent
d15acda
commit 0203102
Showing
29 changed files
with
971 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
.vscode/** | ||
typings/** | ||
out/test/** | ||
out/test-integration/** | ||
test/** | ||
test-integration/** | ||
src/** | ||
**/*.map | ||
.gitignore | ||
tsconfig.json | ||
gulpfile.js | ||
tsd.json | ||
tslint.json | ||
team-extension.log | ||
team-extension.log | ||
**/*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
test-integration/clients/teamservicesclient.integration.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
"use strict"; | ||
|
||
import { Mocks } from "../helpers-integration/mocks"; | ||
import { TestSettings } from "../helpers-integration/testsettings"; | ||
|
||
import { CredentialManager } from "../../src/helpers/credentialmanager"; | ||
import { TeamServerContext } from "../../src/contexts/servercontext"; | ||
import { QTeamServicesApi } from "../../src/clients/teamservicesclient"; | ||
|
||
var chai = require("chai"); | ||
/* tslint:disable:no-unused-variable */ | ||
var expect = chai.expect; | ||
/* tslint:enable:no-unused-variable */ | ||
var assert = chai.assert; | ||
chai.should(); | ||
|
||
describe("TeamServicesClient-Integration", function() { | ||
this.timeout(TestSettings.SuiteTimeout()); //http://mochajs.org/#timeouts | ||
|
||
var credentialManager: CredentialManager = new CredentialManager(); | ||
var ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl()); | ||
|
||
before(function() { | ||
return credentialManager.StoreCredentials(TestSettings.Account(), TestSettings.AccountUser(), TestSettings.Password()); | ||
}); | ||
beforeEach(function() { | ||
return credentialManager.GetCredentialHandler(ctx, undefined); | ||
}); | ||
//afterEach(function() { }); | ||
after(function() { | ||
return credentialManager.RemoveCredentials(TestSettings.Account()); | ||
}); | ||
|
||
it("should verify repositoryClient.getVstsInfo", function(done) { | ||
this.timeout(TestSettings.TestTimeout()); //http://mochajs.org/#timeouts | ||
|
||
let repositoryClient: QTeamServicesApi = new QTeamServicesApi(TestSettings.RemoteRepositoryUrl(), [CredentialManager.GetCredentialHandler()]); | ||
repositoryClient.getVstsInfo().then( | ||
function (repoInfo) { | ||
//console.log(repoInfo); | ||
assert.isNotNull(repoInfo, "repoInfo was null when it shouldn't have been"); | ||
assert.equal(repoInfo.serverUrl, TestSettings.AccountUrl()); | ||
assert.equal(repoInfo.collection.name, TestSettings.CollectionName()); | ||
assert.equal(repoInfo.repository.remoteUrl, TestSettings.RemoteRepositoryUrl()); | ||
assert.equal(repoInfo.repository.id, TestSettings.RepositoryId()); | ||
expect(repoInfo.repository.name).to.equal(TestSettings.RepositoryName()); | ||
done(); | ||
}, | ||
function (err) { | ||
done(err); | ||
} | ||
); | ||
}); | ||
|
||
it("should verify accountClient.connect", function(done) { | ||
this.timeout(TestSettings.TestTimeout()); //http://mochajs.org/#timeouts | ||
|
||
let accountClient: QTeamServicesApi = new QTeamServicesApi(TestSettings.AccountUrl(), [CredentialManager.GetCredentialHandler()]); | ||
accountClient.connect().then( | ||
function (settings) { | ||
//console.log(settings); | ||
assert.isNotNull(settings, "settings was null when it shouldn't have been"); | ||
assert.isNotNull(settings.providerDisplayName); | ||
assert.isNotNull(settings.customDisplayName); | ||
assert.isNotNull(settings.authorizedUser.providerDisplayName); | ||
assert.isNotNull(settings.authorizedUser.customDisplayName); | ||
done(); | ||
}, | ||
function (err) { | ||
done(err); | ||
} | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
"use strict"; | ||
|
||
import { TeamServerContext } from "../../src/contexts/servercontext"; | ||
import { RepositoryInfo } from "../../src/info/repositoryinfo"; | ||
import { TestSettings } from "./testsettings"; | ||
|
||
export class Mocks { | ||
|
||
public static TeamServerContext(repositoryUrl: string) : TeamServerContext { | ||
return new TeamServerContext(repositoryUrl); | ||
} | ||
|
||
public static RepositoryInfo() : RepositoryInfo { | ||
let repositoryInfo : any = { | ||
"serverUrl":"undefined", | ||
"collection":{ | ||
"id":"undefined", | ||
"name":"undefined", | ||
"url":"undefined" | ||
}, | ||
"repository":{ | ||
"id":"undefined", | ||
"name":"undefined", | ||
"url":"undefined", | ||
"project":{ | ||
"id":"undefined", | ||
"name":"undefined", | ||
"url":"undefined", | ||
"state":1, | ||
"revision":115 | ||
}, | ||
"remoteUrl":"undefined" | ||
} | ||
}; | ||
repositoryInfo.serverUrl = TestSettings.AccountUrl(); | ||
repositoryInfo.collection.name = TestSettings.CollectionName(); | ||
repositoryInfo.collection.url = TestSettings.AccountUrl() + "/_apis/projectCollections/" + TestSettings.CollectionGuid(); | ||
repositoryInfo.repository.id = TestSettings.RepositoryId(); | ||
repositoryInfo.repository.name = TestSettings.RepositoryName(); | ||
repositoryInfo.repository.url = TestSettings.AccountUrl() + "/DefaultCollection/_apis/git/repositories/" + TestSettings.RepositoryId(); | ||
repositoryInfo.repository.project.name = TestSettings.TeamProject(); | ||
repositoryInfo.repository.project.url = TestSettings.AccountUrl() + "/DefaultCollection/_apis/projects/" + + TestSettings.ProjectGuid(); | ||
repositoryInfo.repository.remoteUrl = TestSettings.RemoteRepositoryUrl(); | ||
|
||
return new RepositoryInfo(repositoryInfo); | ||
} | ||
} |
Oops, something went wrong.