@@ -2121,6 +2121,86 @@ describe('modules/manager/gomod/artifacts', () => {
2121
2121
expect ( execSnapshots ) . toMatchObject ( expectedResult ) ;
2122
2122
} ) ;
2123
2123
2124
+ it ( 'go.mod file contains go toolchain version' , async ( ) => {
2125
+ GlobalConfig . set ( { ...adminConfig , binarySource : 'install' } ) ;
2126
+ fs . readLocalFile . mockResolvedValueOnce ( 'Current go.sum' ) ;
2127
+ fs . readLocalFile . mockResolvedValueOnce ( null ) ; // vendor modules filename
2128
+ const execSnapshots = mockExecAll ( ) ;
2129
+ git . getRepoStatus . mockResolvedValueOnce (
2130
+ partial < StatusResult > ( {
2131
+ modified : [ 'go.sum' ] ,
2132
+ } ) ,
2133
+ ) ;
2134
+ fs . readLocalFile
2135
+ . mockResolvedValueOnce ( 'New go.sum' )
2136
+ . mockResolvedValueOnce ( 'New go.mod' ) ;
2137
+
2138
+ const res = await gomod . updateArtifacts ( {
2139
+ packageFileName : 'go.mod' ,
2140
+ updatedDeps : [ { depName : 'golang.org/x/crypto' , newVersion : '0.35.0' } ] ,
2141
+ newPackageFileContent : `someText\n\ngo 1.13\n\ntoolchain go1.23.6\n\n${ gomod1 } ` ,
2142
+ config : {
2143
+ updateType : 'minor' ,
2144
+ } ,
2145
+ } ) ;
2146
+
2147
+ expect ( res ) . toEqual ( [
2148
+ { file : { type : 'addition' , path : 'go.sum' , contents : 'New go.sum' } } ,
2149
+ { file : { type : 'addition' , path : 'go.mod' , contents : 'New go.mod' } } ,
2150
+ ] ) ;
2151
+
2152
+ expect ( execSnapshots ) . toMatchObject ( [
2153
+ {
2154
+ cmd : 'install-tool golang 1.23.6' ,
2155
+ } ,
2156
+ {
2157
+ cmd : 'go get -d -t ./...' ,
2158
+ } ,
2159
+ ] ) ;
2160
+
2161
+ expect ( datasource . getPkgReleases ) . toBeCalledTimes ( 0 ) ;
2162
+ } ) ;
2163
+
2164
+ it ( 'go.mod file contains full go version without toolchain' , async ( ) => {
2165
+ GlobalConfig . set ( { ...adminConfig , binarySource : 'install' } ) ;
2166
+ fs . readLocalFile . mockResolvedValueOnce ( 'Current go.sum' ) ;
2167
+ fs . readLocalFile . mockResolvedValueOnce ( null ) ; // vendor modules filename
2168
+ const execSnapshots = mockExecAll ( ) ;
2169
+ git . getRepoStatus . mockResolvedValueOnce (
2170
+ partial < StatusResult > ( {
2171
+ modified : [ 'go.sum' ] ,
2172
+ } ) ,
2173
+ ) ;
2174
+ fs . readLocalFile
2175
+ . mockResolvedValueOnce ( 'New go.sum' )
2176
+ . mockResolvedValueOnce ( 'New go.mod' ) ;
2177
+
2178
+ const res = await gomod . updateArtifacts ( {
2179
+ packageFileName : 'go.mod' ,
2180
+ updatedDeps : [ { depName : 'golang.org/x/crypto' , newVersion : '0.35.0' } ] ,
2181
+ newPackageFileContent : `someText\n\ngo 1.23.5\n\n${ gomod1 } ` ,
2182
+ config : {
2183
+ updateType : 'minor' ,
2184
+ } ,
2185
+ } ) ;
2186
+
2187
+ expect ( res ) . toEqual ( [
2188
+ { file : { type : 'addition' , path : 'go.sum' , contents : 'New go.sum' } } ,
2189
+ { file : { type : 'addition' , path : 'go.mod' , contents : 'New go.mod' } } ,
2190
+ ] ) ;
2191
+
2192
+ expect ( execSnapshots ) . toMatchObject ( [
2193
+ {
2194
+ cmd : 'install-tool golang 1.23.5' ,
2195
+ } ,
2196
+ {
2197
+ cmd : 'go get -d -t ./...' ,
2198
+ } ,
2199
+ ] ) ;
2200
+
2201
+ expect ( datasource . getPkgReleases ) . toBeCalledTimes ( 0 ) ;
2202
+ } ) ;
2203
+
2124
2204
it ( 'returns artifact notices' , async ( ) => {
2125
2205
artifactsExtra . getExtraDepsNotice . mockReturnValue ( 'some extra notice' ) ;
2126
2206
GlobalConfig . set ( { ...adminConfig , binarySource : 'docker' } ) ;
@@ -2144,7 +2224,7 @@ describe('modules/manager/gomod/artifacts', () => {
2144
2224
updatedDeps : [
2145
2225
{ depName : 'github.com/google/go-github/v24' , newVersion : 'v28.0.0' } ,
2146
2226
] ,
2147
- newPackageFileContent : gomod1 ,
2227
+ newPackageFileContent : `someText\n\ngo 1.17\n\n ${ gomod1 } ` ,
2148
2228
config : {
2149
2229
updateType : 'major' ,
2150
2230
postUpdateOptions : [ 'gomodUpdateImportPaths' ] ,
0 commit comments