Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,9 @@ func TestVolumes(t *testing.T) {
time.Sleep(5 * time.Second)

mountOpts := map[string]string{
"type": "none",
"options": "bind",
"mountpoint": "/some-path",
"mountpoint": "/tmp",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve maintainability and avoid magic strings, it's a good practice to define /tmp as a constant, especially since it's used in multiple places within this test (here and in wantOptions on line 532).

You could define it at the beginning of the TestVolumes function:

func TestVolumes(t *testing.T) {
	const mountPath = "/tmp"
	// ...
}

Then use mountPath in both places.

References
  1. According to the Go Code Review Comments guide, constants should be used for any magic values to improve readability and maintainability. The string "/tmp" is a magic value repeated in the test. (link)

}

createdVolumeName, err := cli.CreateVolume(ctx, volumeName, "local", nil, mountOpts)
Expand Down Expand Up @@ -528,7 +529,7 @@ func TestVolumes(t *testing.T) {

// check options
wantOptions := map[string]string{
"device": "/some-path",
"device": "/tmp",
"o": "bind",
"type": "none",
}
Expand Down
Loading