fix bug with empty boot command.
This commit is contained in:
parent
bcbee45bf9
commit
e4bd30e53d
|
@ -75,11 +75,14 @@ func (s expressionSequence) Validate() (errs []error) {
|
||||||
// GenerateExpressionSequence generates a sequence of expressions from the
|
// GenerateExpressionSequence generates a sequence of expressions from the
|
||||||
// given command. This is the primary entry point to the boot command parser.
|
// given command. This is the primary entry point to the boot command parser.
|
||||||
func GenerateExpressionSequence(command string) (expressionSequence, error) {
|
func GenerateExpressionSequence(command string) (expressionSequence, error) {
|
||||||
|
seq := expressionSequence{}
|
||||||
|
if command == "" {
|
||||||
|
return seq, nil
|
||||||
|
}
|
||||||
got, err := ParseReader("", strings.NewReader(command))
|
got, err := ParseReader("", strings.NewReader(command))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
seq := expressionSequence{}
|
|
||||||
for _, exp := range got.([]interface{}) {
|
for _, exp := range got.([]interface{}) {
|
||||||
seq = append(seq, exp.(expression))
|
seq = append(seq, exp.(expression))
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,3 +138,9 @@ func Test_validation(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_empty(t *testing.T) {
|
||||||
|
exp, err := GenerateExpressionSequence("")
|
||||||
|
assert.NoError(t, err, "should have parsed an empty input okay.")
|
||||||
|
assert.Len(t, exp, 0)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue