File tree 3 files changed +33
-4
lines changed
3 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -904,6 +904,29 @@ use .
904
904
) ;
905
905
} ) ;
906
906
907
+ it ( 'go-version accepts a go.mod file' , async ( ) => {
908
+ inputs [ 'go-version' ] = 'go.mod' ;
909
+ existsSpy . mockImplementation ( ( ) => true ) ;
910
+ readFileSpy . mockImplementation ( ( ) => Buffer . from ( goModContents ) ) ;
911
+
912
+ await main . run ( ) ;
913
+
914
+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Setup go version spec 1.14' ) ;
915
+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Attempting to download 1.14...' ) ;
916
+ expect ( logSpy ) . toHaveBeenCalledWith ( 'matching 1.14...' ) ;
917
+ } ) ;
918
+
919
+ it ( 'go-version reports a read failure' , async ( ) => {
920
+ inputs [ 'go-version' ] = 'path/to/go.mod' ;
921
+ existsSpy . mockImplementation ( ( ) => false ) ;
922
+
923
+ await main . run ( ) ;
924
+
925
+ expect ( cnSpy ) . toHaveBeenCalledWith (
926
+ `::error::The specified go version file at: path/to/go.mod does not exist${ osm . EOL } `
927
+ ) ;
928
+ } ) ;
929
+
907
930
it ( 'acquires specified architecture of go' , async ( ) => {
908
931
for ( const { arch, version, osSpec} of [
909
932
{ arch : 'amd64' , version : '1.13.7' , osSpec : 'linux' } ,
Original file line number Diff line number Diff line change @@ -88749,12 +88749,15 @@ function parseGoVersion(versionString) {
88749
88749
exports.parseGoVersion = parseGoVersion;
88750
88750
function resolveVersionInput() {
88751
88751
let version = core.getInput('go-version');
88752
- const versionFilePath = core.getInput('go-version-file');
88752
+ let versionFilePath = core.getInput('go-version-file');
88753
88753
if (version && versionFilePath) {
88754
88754
core.warning('Both go-version and go-version-file inputs are specified, only go-version will be used');
88755
88755
}
88756
88756
if (version) {
88757
- return version;
88757
+ if (!version.endsWith('go.mod')) {
88758
+ return version;
88759
+ }
88760
+ versionFilePath = version;
88758
88761
}
88759
88762
if (versionFilePath) {
88760
88763
if (!fs_1.default.existsSync(versionFilePath)) {
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ export function parseGoVersion(versionString: string): string {
137
137
138
138
function resolveVersionInput ( ) : string {
139
139
let version = core . getInput ( 'go-version' ) ;
140
- const versionFilePath = core . getInput ( 'go-version-file' ) ;
140
+ let versionFilePath = core . getInput ( 'go-version-file' ) ;
141
141
142
142
if ( version && versionFilePath ) {
143
143
core . warning (
@@ -146,7 +146,10 @@ function resolveVersionInput(): string {
146
146
}
147
147
148
148
if ( version ) {
149
- return version ;
149
+ if ( ! version . endsWith ( 'go.mod' ) ) {
150
+ return version ;
151
+ }
152
+ versionFilePath = version ;
150
153
}
151
154
152
155
if ( versionFilePath ) {
You can’t perform that action at this time.
0 commit comments