Skip to content

Commit

Permalink
Add test cases and docString for regex in COPY command (#2773)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeJu committed Oct 10, 2023
1 parent c8c839a commit b6f14ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/commands/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (c *CopyCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.Bu
return errors.Wrap(err, "getting user group from chown")
}

// sources from the Copy command are resolved with wildcards {*?[}
srcs, dest, err := util.ResolveEnvAndWildcards(c.cmd.SourcesAndDest, c.fileContext, replacementEnvs)
if err != nil {
return errors.Wrap(err, "resolving src")
Expand Down
15 changes: 15 additions & 0 deletions pkg/commands/copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ var copyTests = []struct {
sourcesAndDest: []string{"foo", "tempCopyExecuteTest"},
expectedDest: []string{"tempCopyExecuteTest"},
},
{
name: "copy f* into tempCopyExecuteTest",
sourcesAndDest: []string{"foo*", "tempCopyExecuteTest"},
expectedDest: []string{"tempCopyExecuteTest"},
},
{
name: "copy fo? into tempCopyExecuteTest",
sourcesAndDest: []string{"fo?", "tempCopyExecuteTest"},
expectedDest: []string{"tempCopyExecuteTest"},
},
{
name: "copy f[o][osp] into tempCopyExecuteTest",
sourcesAndDest: []string{"f[o][osp]", "tempCopyExecuteTest"},
expectedDest: []string{"tempCopyExecuteTest"},
},
}

func setupTestTemp(t *testing.T) string {
Expand Down

0 comments on commit b6f14ae

Please sign in to comment.