@@ -28,7 +28,14 @@ describe('UnifyReleaseService', () => {
2828 } )
2929
3030 describe ( 'unifyRelease' , ( ) => {
31- it ( "Should create tag if all last related builds are Completed and Succeeded or Partially Suceeded" , async ( ) => {
31+ var relatedBuildsStub = null ;
32+ var buildServiceStub : StubbedInstance < IBuildService > = null
33+ beforeEach ( ( ) => {
34+ relatedBuildsStub = new Map < string , Build > ( ) ;
35+ buildServiceStub = StubInterface < IBuildService > ( ) ;
36+ } )
37+
38+ function createBuildServiceStubs ( relatedBuilds : Build [ ] ) {
3239 let triggeredBuild : Build = {
3340 id : 1 ,
3441 definition : {
@@ -37,6 +44,22 @@ describe('UnifyReleaseService', () => {
3744 status : BuildStatus . InProgress ,
3845 sourceVersion : "sourceVersion"
3946 } ;
47+
48+ var allBuilds = [ triggeredBuild ] . concat ( relatedBuilds ) ;
49+
50+ buildServiceStub . getBuildInfo
51+ . withArgs (
52+ configStub . teamFoundationCollectionUri , configStub . accessToken , configStub . teamFoundationProject , configStub . currentBuildId )
53+ . returns ( Promise . resolve ( triggeredBuild ) ) ;
54+
55+ buildServiceStub . listRelatedBuilds
56+ . withArgs (
57+ configStub . teamFoundationCollectionUri , configStub . accessToken , configStub . teamFoundationProject , "sourceVersion" , configStub . waitForAllTriggeredBuilds , [ configStub . definition1 , configStub . definition2 , configStub . definition3 , configStub . definition4 , configStub . definition5 ] )
58+ . returns ( Promise . resolve ( relatedBuildsStub ) ) ;
59+
60+ }
61+ it ( "Should create tag if all last related builds are Completed and Succeeded or Partially Suceeded" , async ( ) => {
62+
4063 let build2 : Build = {
4164 id : 2 ,
4265 definition : {
@@ -55,40 +78,58 @@ describe('UnifyReleaseService', () => {
5578 result : BuildResult . PartiallySucceeded ,
5679 sourceVersion : "sourceVersion"
5780 } ;
58- var relatedBuildsStub = new Map < string , Build > ( ) ;
59- relatedBuildsStub . set ( triggeredBuild . definition . id . toString ( ) , triggeredBuild ) ;
60- relatedBuildsStub . set ( build2 . definition . id . toString ( ) , build2 ) ;
61- relatedBuildsStub . set ( build3 . definition . id . toString ( ) , build3 ) ;
62-
63- let buildServiceStub : StubbedInstance < IBuildService > = StubInterface < IBuildService > ( ) ;
64-
65- buildServiceStub . getBuildInfo
66- . withArgs (
67- configStub . teamFoundationCollectionUri , configStub . accessToken , configStub . teamFoundationProject , configStub . currentBuildId )
68- . returns ( Promise . resolve ( triggeredBuild ) ) ;
69-
70- buildServiceStub . listRelatedBuilds
71- . withArgs (
72- configStub . teamFoundationCollectionUri , configStub . accessToken , configStub . teamFoundationProject , "sourceVersion" , configStub . waitForAllTriggeredBuilds , [ configStub . definition1 , configStub . definition2 , configStub . definition3 , configStub . definition4 , configStub . definition5 ] )
73- . returns ( Promise . resolve ( relatedBuildsStub ) ) ;
7481
82+ createBuildServiceStubs ( [ build2 , build3 ] ) ;
83+
7584 let buildServiceCreateTagSpy = buildServiceStub . addBuildTag
7685 . withArgs ( configStub . teamFoundationCollectionUri , configStub . teamFoundationProject , configStub . accessToken , configStub . currentBuildId , configStub . releaseTag ) ;
7786
7887 var unifyReleaseService = new UnifyReleaseService ( buildServiceStub , configStub ) ;
7988
8089 await unifyReleaseService . unifyRelease ( ) ;
8190
82- debugger ;
8391 expect ( buildServiceCreateTagSpy . calledOnce ) . equal ( true ) ;
92+ } ) ;
8493
94+ it ( "Should not create tag if there's a last Build Cancelling and with flag release on cancel on" , async ( ) => {
95+ expect ( true , "Not Implemented" ) . false ;
96+ } ) ;
8597
86- // throw new Error("Not Implemented");
98+ it ( "Should not create tag if there's a last Build Cancelling and with flag release on cancel off" , async ( ) => {
99+ expect ( true , "Not Implemented" ) . false ;
100+ } ) ;
101+
102+ it ( "Should not create tag if there's a last Build Cancelling and with flag release on cancel on" , async ( ) => {
103+ expect ( true , "Not Implemented" ) . false ;
104+ } ) ;
87105
106+ it ( "Should not create tag if there's a last Build cancelled and with flag release on cancel off" , async ( ) => {
107+ expect ( true , "Not Implemented" ) . false ;
88108 } ) ;
89109
90- it ( "Should return last Build from definitions triggered from the same Source Version only for the Build Definitons specified" , async ( ) => {
110+ it ( "Should not create tag if there's a last Build failed and with flag release on failure on" , async ( ) => {
111+ expect ( true , "Not Implemented" ) . false ;
112+ } ) ;
113+
114+ it ( "Should not create tag if there's a last Build failed and with flag release on failure off" , async ( ) => {
115+ expect ( true , "Not Implemented" ) . false ;
116+ } ) ;
117+
118+
119+ it ( "Should not create tag if there's a last Build with Status Queued" , async ( ) => {
120+ expect ( true , "Not Implemented" ) . false ;
121+ } ) ;
122+
123+ it ( "Should not create tag if there's a last Build with Status NotStarted" , async ( ) => {
124+ expect ( true , "Not Implemented" ) . false ;
125+ } ) ;
126+
127+ it ( "Should not create tag if there's a last Build with Status InProgress" , async ( ) => {
128+ expect ( true , "Not Implemented" ) . false ;
129+ } ) ;
91130
131+ it ( "Should not create tag if there's a last Build with Status PostPoned" , async ( ) => {
132+ expect ( true , "Not Implemented" ) . false ;
92133 } ) ;
93134 } ) ;
94135} ) ;
0 commit comments