-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix patching from dir with gomod generator
This is just a difference in how the states are stored when there is a subpath in a directory that is the patch source (as compared to a patch file). Signed-off-by: Brian Goff <[email protected]>
- Loading branch information
Showing
2 changed files
with
47 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,6 +260,7 @@ index ea874f5..ba38f84 100644 | |
|
||
// Note: module here should be moduyle+version because this is checking the go module path on disk | ||
checkModule := func(ctx context.Context, gwc gwclient.Client, module string, spec *dalec.Spec) { | ||
t.Helper() | ||
res, err := gwc.Solve(ctx, newSolveRequest(withBuildTarget("debug/gomods"), withSpec(ctx, t, spec))) | ||
if err != nil { | ||
t.Fatal(err) | ||
|
@@ -314,24 +315,49 @@ index ea874f5..ba38f84 100644 | |
}) | ||
|
||
t.Run("with patch", func(t *testing.T) { | ||
t.Parallel() | ||
testEnv.RunTest(baseCtx, t, func(ctx context.Context, gwc gwclient.Client) { | ||
spec := baseSpec() | ||
t.Run("file", func(t *testing.T) { | ||
t.Parallel() | ||
testEnv.RunTest(baseCtx, t, func(ctx context.Context, gwc gwclient.Client) { | ||
spec := baseSpec() | ||
|
||
patchName := "patch" | ||
spec.Sources[patchName] = dalec.Source{ | ||
Inline: &dalec.SourceInline{ | ||
File: &dalec.SourceInlineFile{ | ||
Contents: downgradePatch, | ||
patchName := "patch" | ||
spec.Sources[patchName] = dalec.Source{ | ||
Inline: &dalec.SourceInline{ | ||
File: &dalec.SourceInlineFile{ | ||
Contents: downgradePatch, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
spec.Patches = map[string][]dalec.PatchSpec{ | ||
srcName: {{Source: patchName}}, | ||
} | ||
spec.Patches = map[string][]dalec.PatchSpec{ | ||
srcName: {{Source: patchName}}, | ||
} | ||
|
||
checkModule(ctx, gwc, "github.com/cpuguy83/[email protected]", spec) | ||
checkModule(ctx, gwc, "github.com/cpuguy83/[email protected]", spec) | ||
}) | ||
}) | ||
t.Run("dir", func(t *testing.T) { | ||
t.Parallel() | ||
testEnv.RunTest(baseCtx, t, func(ctx context.Context, gwc gwclient.Client) { | ||
spec := baseSpec() | ||
|
||
patchName := "patch" | ||
spec.Sources[patchName] = dalec.Source{ | ||
Inline: &dalec.SourceInline{ | ||
Dir: &dalec.SourceInlineDir{ | ||
Files: map[string]*dalec.SourceInlineFile{ | ||
"patch-file": {Contents: downgradePatch}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
spec.Patches = map[string][]dalec.PatchSpec{ | ||
srcName: {{Source: patchName, Path: "patch-file"}}, | ||
} | ||
|
||
checkModule(ctx, gwc, "github.com/cpuguy83/[email protected]", spec) | ||
}) | ||
}) | ||
}) | ||
} |