Skip to content

Commit 1a5b496

Browse files
Patch353 (#354)
* Fixing bug #353 * Bringing code coverage back to 100% * Added TriggerInfo to vsteam_lib.Build * Updated version to 7.0.1 and changelog
1 parent ace10a6 commit 1a5b496

File tree

6 files changed

+200
-3
lines changed

6 files changed

+200
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 7.0.1
4+
5+
Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/354)
6+
7+
- Fixed bug [353](https://github.com/MethodsAndPractices/vsteam/issues/353)
8+
- Added TriggerInfo to vsteam_lib.Build class
9+
310
## 7.0.0
411

512
## Breaking changes

Source/Classes/Provider/Build.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,34 @@ public class Build : Leaf
3434
public string RequestedByUser => this.RequestedBy.DisplayName;
3535
public string RequestedForUser => this.RequestedFor.DisplayName;
3636
public string LastChangedByUser => this.LastChangedBy.DisplayName;
37+
public PSObject TriggerInfo { get; }
3738

3839
public Build(PSObject obj, string projectName, IPowerShell powerShell) :
3940
base(obj, obj.GetValue("buildNumber"), obj.GetValue("Id"), projectName)
4041

4142
{
43+
this.TriggerInfo = obj.GetValue<PSObject>("TriggerInfo");
44+
4245
this.RequestedBy = new User(obj.GetValue<PSObject>("requestedBy"));
4346
this.RequestedFor = new User(obj.GetValue<PSObject>("requestedFor"));
4447
this.LastChangedBy = new User(obj.GetValue<PSObject>("lastChangedBy"));
4548

4649
this.Project = new Project(obj.GetValue<PSObject>("project"), powerShell);
47-
this.Queue = new Queue(obj.GetValue<PSObject>("queue"), projectName, powerShell);
50+
51+
// When you try to use Get-VSTeamBuild on the build that is running sometimes
52+
// the queue is not present yet
53+
if (obj.HasValue("queue"))
54+
{
55+
this.Queue = new Queue(obj.GetValue<PSObject>("queue"), projectName, powerShell);
56+
}
57+
4858
this.BuildDefinition = new BuildDefinition(obj.GetValue<PSObject>("definition"), projectName, powerShell);
4959
}
5060

5161
[ExcludeFromCodeCoverage]
5262
public Build(PSObject obj, string projectName) :
5363
this(obj, projectName, new PowerShellWrapper(RunspaceMode.CurrentRunspace))
54-
{
64+
{
5565
}
5666
}
5767
}

Source/VSTeam.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'VSTeam.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '7.0.0'
15+
ModuleVersion = '7.0.1'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = @('Core', 'Desktop')
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"_links": {
3+
"self": {
4+
"href": "https://dev.azure.com/LoECDA/00000000-0000-0000-0000-000000000000/_apis/build/Builds/2272"
5+
},
6+
"web": {
7+
"href": "https://dev.azure.com/LoECDA/00000000-0000-0000-0000-000000000000/_build/results?buildId=2272"
8+
},
9+
"sourceVersionDisplayUri": {
10+
"href": "https://dev.azure.com/LoECDA/00000000-0000-0000-0000-000000000000/_apis/build/builds/2272/sources"
11+
},
12+
"timeline": {
13+
"href": "https://dev.azure.com/LoECDA/00000000-0000-0000-0000-000000000000/_apis/build/builds/2272/Timeline"
14+
},
15+
"badge": {
16+
"href": "https://dev.azure.com/LoECDA/00000000-0000-0000-0000-000000000000/_apis/build/status/65"
17+
}
18+
},
19+
"properties": {},
20+
"tags": [],
21+
"validationResults": [],
22+
"plans": [
23+
{
24+
"planId": "00000000-0000-0000-0000-000000000000"
25+
}
26+
],
27+
"triggerInfo": {},
28+
"id": 2272,
29+
"buildNumber": "2272",
30+
"status": "inProgress",
31+
"queueTime": "2020-09-23T15:44:09.2919724Z",
32+
"startTime": "2020-09-23T15:44:45.2487227Z",
33+
"url": "https://dev.azure.com/LoECDA/00000000-0000-0000-0000-000000000000/_apis/build/Builds/2272",
34+
"definition": {
35+
"drafts": [],
36+
"id": 65,
37+
"name": "Team Module-CI (1)",
38+
"url": "https://dev.azure.com/LoECDA/00000000-0000-0000-0000-000000000000/_apis/build/Definitions/65?revision=7",
39+
"uri": "vstfs:///Build/Definition/65",
40+
"path": "\\",
41+
"type": "build",
42+
"queueStatus": "enabled",
43+
"revision": 7,
44+
"project": {
45+
"id": "00000000-0000-0000-0000-000000000000",
46+
"name": "Team Module",
47+
"description": "This is a PowerShell module named Team for using TFS and VSTS from PowerShell. The code is Open source in GitHub.",
48+
"url": "https://dev.azure.com/LoECDA/_apis/projects/00000000-0000-0000-0000-000000000000",
49+
"state": "wellFormed",
50+
"revision": 357,
51+
"visibility": "public",
52+
"lastUpdateTime": "2019-06-18T13:57:23.407Z"
53+
}
54+
},
55+
"project": {
56+
"id": "00000000-0000-0000-0000-000000000000",
57+
"name": "Team Module",
58+
"description": "This is a PowerShell module named Team for using TFS and VSTS from PowerShell. The code is Open source in GitHub.",
59+
"url": "https://dev.azure.com/LoECDA/_apis/projects/00000000-0000-0000-0000-000000000000",
60+
"state": "wellFormed",
61+
"revision": 357,
62+
"visibility": "public",
63+
"lastUpdateTime": "2019-06-18T13:57:23.407Z"
64+
},
65+
"uri": "vstfs:///Build/Build/2272",
66+
"sourceBranch": "refs/heads/master",
67+
"sourceVersion": "ace10a62d0f840e0c63ffc088983d3a20d4463d5",
68+
"priority": "normal",
69+
"reason": "manual",
70+
"requestedFor": {
71+
"displayName": "Donovan Brown",
72+
"url": "https://spsprodcus1.vssps.visualstudio.com/00000000-0000-0000-0000-000000000000/_apis/Identities/00000000-0000-0000-0000-000000000000",
73+
"_links": {
74+
"avatar": {
75+
"href": "https://dev.azure.com/LoECDA/_apis/GraphProfile/MemberAvatars/aad.redacted"
76+
}
77+
},
78+
"id": "00000000-0000-0000-0000-000000000000",
79+
"uniqueName": "[email protected]",
80+
"imageUrl": "https://dev.azure.com/LoECDA/_apis/GraphProfile/MemberAvatars/aad.redacted",
81+
"descriptor": "aad.redacted"
82+
},
83+
"requestedBy": {
84+
"displayName": "Donovan Brown",
85+
"url": "https://spsprodcus1.vssps.visualstudio.com/00000000-0000-0000-0000-000000000000/_apis/Identities/00000000-0000-0000-0000-000000000000",
86+
"_links": {
87+
"avatar": {
88+
"href": "https://dev.azure.com/LoECDA/_apis/GraphProfile/MemberAvatars/aad.redacted"
89+
}
90+
},
91+
"id": "00000000-0000-0000-0000-000000000000",
92+
"uniqueName": "[email protected]",
93+
"imageUrl": "https://dev.azure.com/LoECDA/_apis/GraphProfile/MemberAvatars/aad.redacted",
94+
"descriptor": "aad.redacted"
95+
},
96+
"lastChangedDate": "2020-09-23T15:44:45.26Z",
97+
"lastChangedBy": {
98+
"displayName": "Microsoft.VisualStudio.Services.TFS",
99+
"url": "https://spsprodcus1.vssps.visualstudio.com/00000000-0000-0000-0000-000000000000/_apis/Identities/00000000-0000-0000-0000-000000000000",
100+
"_links": {
101+
"avatar": {
102+
"href": "https://dev.azure.com/LoECDA/_apis/GraphProfile/MemberAvatars/s2s.MDAwMDAwMDItMDAwMC04ODg4LTgwMDAtMDAwMDAwMDAwMDAwQDJjODk1OTA4LTA0ZTAtNDk1Mi04OWZkLTU0YjAwNDZkNjI4OA"
103+
}
104+
},
105+
"id": "00000000-0000-0000-0000-000000000000",
106+
"uniqueName": "00000000-0000-0000-0000-000000000000@00000000-0000-0000-0000-000000000000",
107+
"imageUrl": "https://dev.azure.com/LoECDA/_apis/GraphProfile/MemberAvatars/s2s.MDAwMDAwMDItMDAwMC04ODg4LTgwMDAtMDAwMDAwMDAwMDAwQDJjODk1OTA4LTA0ZTAtNDk1Mi04OWZkLTU0YjAwNDZkNjI4OA",
108+
"descriptor": "s2s.MDAwMDAwMDItMDAwMC04ODg4LTgwMDAtMDAwMDAwMDAwMDAwQDJjODk1OTA4LTA0ZTAtNDk1Mi04OWZkLTU0YjAwNDZkNjI4OA"
109+
},
110+
"parameters": "{\"system.debug\":\"false\"}",
111+
"orchestrationPlan": {
112+
"planId": "00000000-0000-0000-0000-000000000000"
113+
},
114+
"logs": {
115+
"id": 0,
116+
"type": "Container",
117+
"url": "https://dev.azure.com/LoECDA/00000000-0000-0000-0000-000000000000/_apis/build/builds/2272/logs"
118+
},
119+
"repository": {
120+
"id": "MethodsAndPractices/vsteam",
121+
"type": "GitHub",
122+
"clean": null,
123+
"checkoutSubmodules": false
124+
},
125+
"keepForever": false,
126+
"retainedByRelease": false,
127+
"triggeredByBuild": null
128+
}

Tests/library/Provider/BuildTests.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public void Build_Constructor()
3333
Assert.AreEqual("11/14/2019 12:49:37 AM", actual.StartTime.ToString(), "startTime");
3434
Assert.AreEqual("Microsoft.VisualStudio.Services.ReleaseManagement", actual.LastChangedByUser, "LastChangedByUser");
3535

36+
Assert.IsNotNull(actual.TriggerInfo, "TriggerInfo");
37+
3638
Assert.IsNotNull(actual.Queue, "Queue");
3739
Assert.IsNotNull(actual.Queue.Pool, "Queue.Pool");
3840
Assert.AreEqual("81", actual.Queue.Id, "Queue.Id");
@@ -50,5 +52,54 @@ public void Build_Constructor()
5052
Assert.AreEqual("Donovan Brown", actual.RequestedFor.DisplayName, "RequestedFor.DisplayName");
5153
Assert.AreEqual("Microsoft.VisualStudio.Services.ReleaseManagement", actual.LastChangedBy.ToString(), "LastChangedBy.ToString()");
5254
}
55+
56+
57+
/// <summary>
58+
/// This sample file is one you would get if you called Get-VSTeamBuild
59+
/// by ID on a agent for the build that is running. In this case the
60+
/// Queue would not be set yet.
61+
/// </summary>
62+
[TestMethod]
63+
public void Build_Constructor_ById()
64+
{
65+
// Arrange
66+
var ps = BaseTests.PrepPowerShell();
67+
var obj = BaseTests.LoadJson("Get-VSTeamBuild-Id.json", false);
68+
69+
// Act
70+
var actual = new Build(obj[0], "Project Name", ps);
71+
72+
// Assert
73+
Assert.IsNull(actual.Queue, "Queue");
74+
Assert.AreEqual(null, actual.QueueId, "QueueId");
75+
Assert.AreEqual(null, actual.QueueName, "QueueName");
76+
77+
Assert.AreEqual(null, actual.Result, "Result");
78+
Assert.IsNotNull(actual.RequestedBy, "RequestedBy");
79+
Assert.IsNotNull(actual.RequestedFor, "RequestedFor");
80+
Assert.AreEqual("inProgress", actual.Status, "Status");
81+
Assert.IsNotNull(actual.LastChangedBy, "LastChangedBy");
82+
Assert.AreEqual("2272", actual.BuildNumber, "BuildNumber");
83+
Assert.AreEqual("GitHub", actual.RepositoryType, "RepositoryType");
84+
Assert.AreEqual("Team Module-CI (1)", actual.DefinitionName, "DefinitionName");
85+
Assert.AreEqual("Donovan Brown", actual.RequestedByUser, "RequestedByUser");
86+
Assert.AreEqual("Donovan Brown", actual.RequestedForUser, "RequestedForUser");
87+
Assert.AreEqual("9/23/2020 3:44:45 PM", actual.StartTime.ToString(), "startTime");
88+
Assert.AreEqual("Microsoft.VisualStudio.Services.TFS", actual.LastChangedByUser, "LastChangedByUser");
89+
90+
Assert.IsNotNull(actual.TriggerInfo, "TriggerInfo");
91+
92+
Assert.IsNotNull(actual.BuildDefinition, "BuildDefinition");
93+
Assert.AreEqual(65, actual.BuildDefinition.Id, "BuildDefinition.Id");
94+
Assert.AreEqual("Team Module-CI (1)", actual.BuildDefinition.Name, "BuildDefinition.Name");
95+
96+
Assert.IsNotNull(actual.Project, "Project");
97+
Assert.AreEqual("Team Module", actual.Project.Name, "Project.Name");
98+
Assert.AreEqual("00000000-0000-0000-0000-000000000000", actual.Project.Id, "Project.Id");
99+
100+
Assert.AreEqual("[email protected]", actual.RequestedBy.UniqueName, "RequestedBy.UniqueName");
101+
Assert.AreEqual("Donovan Brown", actual.RequestedFor.DisplayName, "RequestedFor.DisplayName");
102+
Assert.AreEqual("Microsoft.VisualStudio.Services.TFS", actual.LastChangedBy.ToString(), "LastChangedBy.ToString()");
103+
}
53104
}
54105
}

Tests/library/Provider/ClassificationNodeTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public void ClassificationNodeTests_Constructor()
2222
Assert.IsNotNull(target.Children, "Children");
2323
Assert.AreEqual(true, target.HasChildren, "HasChildren");
2424
Assert.AreEqual(Guid.Empty, target.Identifier, "Identifier");
25+
Assert.AreEqual(target.Id, target.NodeId.ToString(), "NodeId");
2526
Assert.AreEqual("\\PeopleTracker\\Iteration", target.Path, "Path");
2627
Assert.AreEqual("iteration", target.StructureType, "StructureType");
2728
Assert.AreEqual("https://dev.azure.com/Test/00000000-0000-0000-0000-000000000000/_apis/wit/classificationNodes/Iterations", target.Url, "Url");

0 commit comments

Comments
 (0)