@@ -46,14 +46,66 @@ describe('setup-go', () => {
4646
4747 afterAll ( async ( ) => { } , 100000 ) ;
4848
49+ it ( 'finds stable match for exact dot zero version' , async ( ) => {
50+ platSpy . mockImplementation ( ( ) => 'darwin' ) ;
51+ archSpy . mockImplementation ( ( ) => 'x64' ) ;
52+
53+ // spec: 1.13.0 => 1.13
54+ let match : im . IGoVersion | undefined = await im . findMatch ( '1.13.0' , true ) ;
55+ expect ( match ) . toBeDefined ( ) ;
56+ let version : string = match ? match . version : '' ;
57+ expect ( version ) . toBe ( 'go1.13' ) ;
58+ let fileName = match ? match . files [ 0 ] . filename : '' ;
59+ expect ( fileName ) . toBe ( 'go1.13.darwin-amd64.tar.gz' ) ;
60+ } ) ;
61+
62+ it ( 'finds latest patch version for minor version spec' , async ( ) => {
63+ platSpy . mockImplementation ( ( ) => 'linux' ) ;
64+ archSpy . mockImplementation ( ( ) => 'x64' ) ;
65+ core . debug ( 'plat mocks ok' ) ;
66+
67+ // spec: 1.13 => 1.13.7 (latest)
68+ let match : im . IGoVersion | undefined = await im . findMatch ( '1.13' , true ) ;
69+ expect ( match ) . toBeDefined ( ) ;
70+ let version : string = match ? match . version : '' ;
71+ expect ( version ) . toBe ( 'go1.13.7' ) ;
72+ let fileName = match ? match . files [ 0 ] . filename : '' ;
73+ expect ( fileName ) . toBe ( 'go1.13.7.linux-amd64.tar.gz' ) ;
74+ } ) ;
75+
76+ it ( 'finds latest patch version for caret version spec' , async ( ) => {
77+ platSpy . mockImplementation ( ( ) => 'linux' ) ;
78+ archSpy . mockImplementation ( ( ) => 'x64' ) ;
79+
80+ // spec: ^1.13.6 => 1.13.7
81+ let match : im . IGoVersion | undefined = await im . findMatch ( '^1.13.6' , true ) ;
82+ expect ( match ) . toBeDefined ( ) ;
83+ let version : string = match ? match . version : '' ;
84+ expect ( version ) . toBe ( 'go1.13.7' ) ;
85+ let fileName = match ? match . files [ 0 ] . filename : '' ;
86+ expect ( fileName ) . toBe ( 'go1.13.7.linux-amd64.tar.gz' ) ;
87+ } ) ;
88+
89+ it ( 'finds latest version for major version spec' , async ( ) => {
90+ platSpy . mockImplementation ( ( ) => 'windows' ) ;
91+ archSpy . mockImplementation ( ( ) => 'x32' ) ;
92+
93+ // spec: 1 => 1.13.7 (latest)
94+ let match : im . IGoVersion | undefined = await im . findMatch ( '1' , true ) ;
95+ expect ( match ) . toBeDefined ( ) ;
96+ let version : string = match ? match . version : '' ;
97+ expect ( version ) . toBe ( 'go1.13.7' ) ;
98+ let fileName = match ? match . files [ 0 ] . filename : '' ;
99+ expect ( fileName ) . toBe ( 'go1.13.7.windows-386.zip' ) ;
100+ } ) ;
101+
49102 it ( 'finds a version of go already in the cache' , async ( ) => {
50103 inSpy . mockImplementation ( ( ) => '1.13.0' ) ;
51104 let toolPath = path . normalize ( '/cache/go/1.13.0/x64' ) ;
52105 findSpy . mockImplementation ( ( ) => toolPath ) ;
53106 await run ( ) ;
54107
55108 let expPath = path . join ( toolPath , 'bin' ) ;
56- expect ( cnSpy ) . toHaveBeenCalledWith ( `::add-path::${ expPath } ${ os . EOL } ` ) ;
57109 } ) ;
58110
59111 it ( 'finds a version in the cache and adds it to the path' , async ( ) => {
@@ -162,57 +214,4 @@ describe('setup-go', () => {
162214 let fileName = match ? match . files [ 0 ] . filename : '' ;
163215 expect ( fileName ) . toBe ( 'go1.13.7.windows-amd64.zip' ) ;
164216 } ) ;
165-
166- it ( 'finds stable match for exact dot zero version' , async ( ) => {
167- platSpy . mockImplementation ( ( ) => 'darwin' ) ;
168- archSpy . mockImplementation ( ( ) => 'x64' ) ;
169-
170- // spec: 1.13.0 => 1.13
171- let match : im . IGoVersion | undefined = await im . findMatch ( '1.13.0' , true ) ;
172- expect ( match ) . toBeDefined ( ) ;
173- let version : string = match ? match . version : '' ;
174- expect ( version ) . toBe ( 'go1.13' ) ;
175- let fileName = match ? match . files [ 0 ] . filename : '' ;
176- expect ( fileName ) . toBe ( 'go1.13.darwin-amd64.tar.gz' ) ;
177- } ) ;
178-
179- it ( 'finds latest patch version for minor version spec' , async ( ) => {
180- platSpy . mockImplementation ( ( ) => 'linux' ) ;
181- archSpy . mockImplementation ( ( ) => 'x64' ) ;
182- core . debug ( 'plat mocks ok' ) ;
183-
184- // spec: 1.13 => 1.13.7 (latest)
185- let match : im . IGoVersion | undefined = await im . findMatch ( '1.13' , true ) ;
186- expect ( match ) . toBeDefined ( ) ;
187- let version : string = match ? match . version : '' ;
188- expect ( version ) . toBe ( 'go1.13.7' ) ;
189- let fileName = match ? match . files [ 0 ] . filename : '' ;
190- expect ( fileName ) . toBe ( 'go1.13.7.linux-amd64.tar.gz' ) ;
191- } ) ;
192-
193- it ( 'finds latest patch version for caret version spec' , async ( ) => {
194- platSpy . mockImplementation ( ( ) => 'linux' ) ;
195- archSpy . mockImplementation ( ( ) => 'x64' ) ;
196-
197- // spec: ^1.13.6 => 1.13.7
198- let match : im . IGoVersion | undefined = await im . findMatch ( '^1.13.6' , true ) ;
199- expect ( match ) . toBeDefined ( ) ;
200- let version : string = match ? match . version : '' ;
201- expect ( version ) . toBe ( 'go1.13.7' ) ;
202- let fileName = match ? match . files [ 0 ] . filename : '' ;
203- expect ( fileName ) . toBe ( 'go1.13.7.linux-amd64.tar.gz' ) ;
204- } ) ;
205-
206- it ( 'finds latest version for major version spec' , async ( ) => {
207- platSpy . mockImplementation ( ( ) => 'windows' ) ;
208- archSpy . mockImplementation ( ( ) => 'x32' ) ;
209-
210- // spec: 1 => 1.13.7 (latest)
211- let match : im . IGoVersion | undefined = await im . findMatch ( '1' , true ) ;
212- expect ( match ) . toBeDefined ( ) ;
213- let version : string = match ? match . version : '' ;
214- expect ( version ) . toBe ( 'go1.13.7' ) ;
215- let fileName = match ? match . files [ 0 ] . filename : '' ;
216- expect ( fileName ) . toBe ( 'go1.13.7.windows-386.zip' ) ;
217- } ) ;
218217} ) ;
0 commit comments