Skip to content

Commit

Permalink
Merge pull request #707 from Letty5411/test0206-2
Browse files Browse the repository at this point in the history
fix: fix volume label error, issue#706
  • Loading branch information
allencloud authored Feb 6, 2018
2 parents 2d43f7f + f7d502c commit b903ebe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func parseVolume(volumeCreateConfig *types.VolumeCreateConfig, v *VolumeCreateCo
// analyze labels.
for _, label := range v.labels {
l := strings.Split(label, "=")
if len(label) != 2 {
if len(l) != 2 {
return fmt.Errorf("unknown label %s: label format must be key=value", label)
}
volumeCreateConfig.Labels[l[0]] = l[1]
Expand Down
13 changes: 13 additions & 0 deletions test/cli_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,16 @@ func (suite *PouchVolumeSuite) TestVolumeCreateWrongDriver(c *check.C) {
command.PouchRun("volume", "create", "--name", funcname, "--driver", "wrongdriver").Compare(expct)
command.PouchRun("volume", "remove", funcname)
}

// TestVolumeCreateWithLabel tests creating volume with label.
func (suite *PouchVolumeSuite) TestVolumeCreateWithLabel(c *check.C) {
pc, _, _, _ := runtime.Caller(0)
tmpname := strings.Split(runtime.FuncForPC(pc).Name(), ".")
var funcname string
for i := range tmpname {
funcname = tmpname[i]
}

command.PouchRun("volume", "create", "--name", funcname, "--label", "test=foo").Assert(c, icmd.Success)
command.PouchRun("volume", "remove", funcname)
}

0 comments on commit b903ebe

Please sign in to comment.