Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: check error message in parts when testing the CreateContainerWithDirs method #576

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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