Skip to content

Commit

Permalink
cmd/format: fix setting quota (#1658)
Browse files Browse the repository at this point in the history
  • Loading branch information
SandyXSD committed Mar 28, 2022
1 parent ab6a02d commit 1e49f93
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ func format(c *cli.Context) error {
for _, flag := range c.LocalFlagNames() {
switch flag {
case "capacity":
format.Capacity = c.Uint64(flag)
format.Capacity = c.Uint64(flag) << 30
case "inodes":
format.Capacity = c.Uint64(flag)
format.Inodes = c.Uint64(flag)
case "bucket":
format.Bucket = c.String(flag)
case "access-key":
Expand Down
13 changes: 13 additions & 0 deletions cmd/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,17 @@ func TestFormat(t *testing.T) {
if f.Name != testVolume {
t.Fatalf("volume name %s != expected %s", f.Name, testVolume)
}

if err = Main([]string{"", "format", testMeta, testVolume, "--capacity", "1", "--inodes", "1000"}); err != nil {
t.Fatalf("format error: %s", err)
}
if body, err = rdb.Get(context.Background(), "setting").Bytes(); err != nil {
t.Fatalf("get setting: %s", err)
}
if err = json.Unmarshal(body, &f); err != nil {
t.Fatalf("json unmarshal: %s", err)
}
if f.Capacity != 1<<30 || f.Inodes != 1000 {
t.Fatalf("unexpected volume: %+v", f)
}
}

0 comments on commit 1e49f93

Please sign in to comment.