Skip to content

Commit

Permalink
test: add test cases for diskquota_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
hellolijj authored and allencloud committed Jan 15, 2019
1 parent e378474 commit 84f7aa6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apis/opts/diskquota.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func ParseDiskQuota(quotas []string) (map[string]string, error) {

for _, quota := range quotas {
if quota == "" {
return nil, fmt.Errorf("invalid format for disk quota: %s", quota)
return nil, fmt.Errorf("invalid format for disk quota: quota cannot be empty string")
}

parts := strings.Split(quota, "=")
Expand Down
3 changes: 2 additions & 1 deletion apis/opts/diskquota_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func TestParseDiskQuota(t *testing.T) {
{name: "test1", args: args{diskquota: []string{""}}, want: nil, wantErr: true},
{name: "test2", args: args{diskquota: []string{"foo=foo=foo"}}, want: nil, wantErr: true},
{name: "test3", args: args{diskquota: []string{"foo"}}, want: map[string]string{"/": "foo"}, wantErr: false},
{name: "test3", args: args{diskquota: []string{"foo=foo"}}, want: map[string]string{"foo": "foo"}, wantErr: false},
{name: "test4", args: args{diskquota: []string{"foo=foo"}}, want: map[string]string{"foo": "foo"}, wantErr: false},
{name: "test5", args: args{diskquota: []string{"foo=foo", "bar=bar"}}, want: map[string]string{"foo": "foo", "bar": "bar"}, wantErr: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 84f7aa6

Please sign in to comment.