spiegel_podman/pkg/machine/env/dir_test.go
ROKUMATE 4a7be9e307 pkg/machine/env: add tests for WithPodmanPrefix
Fixes: #29314
Signed-off-by: ROKUMATE <rohitkumawat0110@gmail.com>
2026-08-14 17:28:31 +05:30

29 lines
807 B
Go

package env_test
import (
"testing"
"github.com/stretchr/testify/assert"
"go.podman.io/podman/v6/pkg/machine/env"
)
func TestWithPodmanPrefix(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{"adds prefix to a bare name", "machine", "podman-machine"},
{"leaves an already-prefixed name unchanged", "podman-machine", "podman-machine"},
{"treats any podman-leading name as already prefixed", "podmanx", "podmanx"},
{"leaves the bare word podman unchanged", "podman", "podman"},
{"prefixes a name that merely contains podman", "mypodman", "podman-mypodman"},
{"prefixes an empty name", "", "podman-"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.expected, env.WithPodmanPrefix(tt.input))
})
}
}