Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
webbnh committed Mar 28, 2024
1 parent e1dfca6 commit 1d9c536
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ func bindMountHelper(t *testing.T, options string) {

connector, _ := getConnector(t, fmt.Sprintf(volumeConfig, options))

//goland:noinspection GoBoolExpressions // The linter cannot tell that this expression is not constant.
if runtime.GOOS == "linux" && options == "" {

Check failure on line 128 in connector_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

string `linux` has 3 occurrences, make it a constant (goconst)
// On Linux, when SELinux is enabled, then bind mounts without
// relabeling options will fail. So, to test this case, disable
// SELinux on the test folder in order to make the file readable
// from within the container.
cmd := exec.Command("chcon", "-Rt", "svirt_sandbox_file_t", "./tests/volume") //nolint:gosec

Check failure on line 133 in connector_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

directive `//nolint:gosec` is unused for linter "gosec" (nolintlint)
assert.NoError(t, cmd.Run())
}

container, err := connector.Deploy(
context.Background(),
"quay.io/arcalot/podman-deployer-test-helper:0.1.0")
Expand All @@ -136,16 +146,21 @@ func bindMountHelper(t *testing.T, options string) {
// Note: If it ends up with length zero buffer, restarting the VM may help:
// https://stackoverflow.com/questions/71977532/podman-mount-host-volume-return-error-statfs-no-such-file-or-directory-in-ma
readBuffer := readOutputUntil(t, container, string(fileContent))
assert.GreaterThan(t, len(readBuffer), 0)
assert.Contains(t, string(readBuffer), string(fileContent))
}

func TestBindMount(t *testing.T) {
scenarios := map[string]string{
"No options": "",
"Private": ":Z",
"Shared": ":z",
"ReadOnly": ":ro",
"Multiple": ":z,ro,noexec",
"Multiple": ":ro,noexec",
"No options": "",
}
//goland:noinspection GoBoolExpressions // The linter cannot tell that this expression is not constant.
if runtime.GOOS == "linux" {
// The SELinux options seem to cause problems on Mac OS X, so only test
// them on Linux.
scenarios["Private"] = ":Z"
scenarios["Shared"] = ":z"
}
for name, s := range scenarios {
options := s
Expand Down

0 comments on commit 1d9c536

Please sign in to comment.