config: return correct error
_conmonVersionFormatErr is a format string and it needs an error argument. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
815258862e
commit
e4edaae628
|
|
@ -459,7 +459,7 @@ func probeConmon(conmonBinary string) error {
|
||||||
|
|
||||||
matches := r.FindStringSubmatch(out.String())
|
matches := r.FindStringSubmatch(out.String())
|
||||||
if len(matches) != 5 {
|
if len(matches) != 5 {
|
||||||
return errors.New(_conmonVersionFormatErr)
|
return fmt.Errorf(_conmonVersionFormatErr, errors.New("invalid version format"))
|
||||||
}
|
}
|
||||||
major, err := strconv.Atoi(matches[2])
|
major, err := strconv.Atoi(matches[2])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -57,7 +58,8 @@ func TestProbeConmon(t *testing.T) {
|
||||||
msg: "failure invalid format",
|
msg: "failure invalid format",
|
||||||
output: "invalid",
|
output: "invalid",
|
||||||
assert: func(err error, msg string) {
|
assert: func(err error, msg string) {
|
||||||
assert.EqualError(t, err, _conmonVersionFormatErr, msg)
|
expectedErr := fmt.Errorf(_conmonVersionFormatErr, errors.New("invalid version format"))
|
||||||
|
assert.Equal(t, err, expectedErr, msg)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue