Skip to content

Commit

Permalink
chore: check error message in parts when testing the CreateContainerW…
Browse files Browse the repository at this point in the history
…ithDirs method (#576)
  • Loading branch information
mdelapenya committed Oct 21, 2022
1 parent be7df34 commit 9bee089
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions docker_test.go
Expand Up @@ -1996,7 +1996,7 @@ func TestDockerCreateContainerWithDirs(t *testing.T) {
tests := []struct {
name string
dir ContainerFile
errMsg string
errMsg []string
}{
{
name: "success copy directory",
Expand All @@ -2013,10 +2013,11 @@ func TestDockerCreateContainerWithDirs(t *testing.T) {
ContainerFilePath: "/tmp/" + hostDirName, // the parent dir must exist
FileMode: 700,
},
errMsg: "can't copy " +
"./testresources123 to container: open " +
"./testresources123: no such file or directory: " +
errMsg: []string{
"can't copy ./testresources123 to container",
"open ./testresources123: no such file or directory",
"failed to create container",
},
},
{
name: "container dir not found",
Expand All @@ -2025,7 +2026,10 @@ func TestDockerCreateContainerWithDirs(t *testing.T) {
ContainerFilePath: "/parent-does-not-exist/testresources123", // does not exist
FileMode: 700,
},
errMsg: "can't copy ./testresources to container: Error: No such container:path",
errMsg: []string{
"can't copy ./testresources to container",
"No such container:path",
},
},
}

Expand All @@ -2043,7 +2047,9 @@ func TestDockerCreateContainerWithDirs(t *testing.T) {

if err != nil {
require.NotEmpty(t, tc.errMsg)
require.Contains(t, err.Error(), tc.errMsg)
for _, msg := range tc.errMsg {
require.Contains(t, err.Error(), msg)
}
} else {
dir := tc.dir

Expand Down

0 comments on commit 9bee089

Please sign in to comment.