summaryrefslogtreecommitdiff
path: root/pkg/specgenutil/volumes_test.go
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2022-04-25 14:48:39 -0500
committerBrent Baude <bbaude@redhat.com>2022-04-25 14:48:39 -0500
commitecd245d8fdfd9f611bd23cebf93c2c23914e5653 (patch)
treee9b0ce975fd7f402c55baa6a953017d448611bf7 /pkg/specgenutil/volumes_test.go
parent6984a0f35704204fa15374aa2c133c4e6e0b366f (diff)
downloadpodman-ecd245d8fdfd9f611bd23cebf93c2c23914e5653.tar.gz
podman-ecd245d8fdfd9f611bd23cebf93c2c23914e5653.tar.bz2
podman-ecd245d8fdfd9f611bd23cebf93c2c23914e5653.zip
Unit tests for pkg/specgenutil pkg/signal
Add some lightweight unit tests to the arsenal. Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/specgenutil/volumes_test.go')
-rw-r--r--pkg/specgenutil/volumes_test.go68
1 files changed, 68 insertions, 0 deletions
diff --git a/pkg/specgenutil/volumes_test.go b/pkg/specgenutil/volumes_test.go
new file mode 100644
index 000000000..fc6caf83c
--- /dev/null
+++ b/pkg/specgenutil/volumes_test.go
@@ -0,0 +1,68 @@
+package specgenutil
+
+import "testing"
+
+func Test_validChownFlag(t *testing.T) {
+ type args struct {
+ flag string
+ }
+ tests := []struct {
+ name string
+ args args
+ want bool
+ wantErr bool
+ }{
+ {
+ name: "U true",
+ args: args{
+ flag: "U=true",
+ },
+ want: true,
+ wantErr: false,
+ },
+ {
+ name: "U true case doesnt matter",
+ args: args{
+ flag: "u=True",
+ },
+ want: true,
+ wantErr: false,
+ },
+ {
+ name: "U is false",
+ args: args{
+ flag: "U=false",
+ },
+ want: false,
+ wantErr: false,
+ },
+ {
+ name: "chown should also work",
+ args: args{
+ flag: "chown=true",
+ },
+ want: true,
+ wantErr: false,
+ },
+ {
+ name: "garbage value should fail",
+ args: args{
+ flag: "U=foobar",
+ },
+ want: false,
+ wantErr: true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ got, err := validChownFlag(tt.args.flag)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("validChownFlag() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if got != tt.want {
+ t.Errorf("validChownFlag() got = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}