aboutsummaryrefslogtreecommitdiff
path: root/pkg/specgenutil/volumes_test.go
blob: fc6caf83c74badef2d46d3504da3bdf3658717dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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)
			}
		})
	}
}