@@ -2199,6 +2199,67 @@ func main() {
21992199 })
22002200 })
22012201
2202+ t .Run ("gomod replace directive incompatible version" , func (t * testing.T ) {
2203+ t .Parallel ()
2204+ ctx := startTestSpan (baseCtx , t )
2205+
2206+ spec := & dalec.Spec {
2207+ Name : "test-gomod-replace-incompatible" ,
2208+ Version : "0.0.1" ,
2209+ Revision : "1" ,
2210+ License : "MIT" ,
2211+ Website : "https://github.com/project-dalec/dalec" ,
2212+ Vendor : "Dalec" ,
2213+ Packager : "Dalec" ,
2214+ Description : "Testing gomod replace directive with in-compatible version" ,
2215+ Sources : map [string ]dalec.Source {
2216+ "src" : {
2217+ Inline : & dalec.SourceInline {
2218+ Dir : & dalec.SourceInlineDir {
2219+ Files : map [string ]* dalec.SourceInlineFile {
2220+ "go.mod" : {Contents : "module example.com/test\n \n go 1.18\n \n require github.com/docker/cli v29.2.1+incompatible\n " },
2221+ "main.go" : {Contents : `package main
2222+
2223+ import _ "github.com/docker/cli/pkg/kvfile"
2224+
2225+ func main() {}
2226+ ` },
2227+ },
2228+ },
2229+ },
2230+ Generate : []* dalec.SourceGenerator {
2231+ {
2232+ Gomod : & dalec.GeneratorGomod {
2233+ Edits : & dalec.GomodEdits {
2234+ Replace : []dalec.GomodReplace {
2235+ {Original : "github.com/docker/cli" , Update : "github.com/docker/cli@v29.2.1" },
2236+ },
2237+ },
2238+ },
2239+ },
2240+ },
2241+ },
2242+ },
2243+ Dependencies : & dalec.PackageDependencies {
2244+ Build : map [string ]dalec.PackageConstraints {
2245+ testConfig .GetPackage ("golang" ): {},
2246+ },
2247+ },
2248+ Build : dalec.ArtifactBuild {
2249+ Steps : []dalec.BuildStep {
2250+ {Command : "grep -F 'replace github.com/docker/cli => github.com/docker/cli v29.2.1+incompatible' ./src/go.mod" },
2251+ {Command : "[ -d \" ${GOMODCACHE}/github.com/docker/cli@v29.2.1+incompatible\" ]" },
2252+ {Command : "cd ./src && go build" },
2253+ },
2254+ },
2255+ }
2256+
2257+ testEnv .RunTest (ctx , t , func (ctx context.Context , client gwclient.Client ) {
2258+ req := newSolveRequest (withBuildTarget (testConfig .Target .Package ), withSpec (ctx , t , spec ))
2259+ solveT (ctx , t , client , req )
2260+ })
2261+ })
2262+
22022263 t .Run ("gomod multi-module with paths" , func (t * testing.T ) {
22032264 t .Parallel ()
22042265 ctx := startTestSpan (baseCtx , t )
0 commit comments