File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ func newExtractor(functionsToCheck []string) (*state, error) {
91
91
// Functions must be of the form "package.function"
92
92
t2 := strings .Split (t , "." )
93
93
if len (t2 ) < 2 {
94
- return nil , errors .Wrap ( nil , fmt . Sprintf ( "Invalid function string %s. Needs package name as well." , t ) )
94
+ return nil , errors .Errorf ( "Invalid function string %s. Needs package name as well." , t )
95
95
}
96
96
f := funcType {
97
97
pack : t2 [0 ],
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package extract
18
18
19
19
import (
20
20
"encoding/json"
21
+ "errors"
21
22
"io/ioutil"
22
23
"os"
23
24
"path/filepath"
@@ -84,3 +85,12 @@ func TestExtract(t *testing.T) {
84
85
}
85
86
86
87
}
88
+
89
+ func TestExtractShouldReturnErrorOnFunctionWithoutPackage (t * testing.T ) {
90
+ expected := errors .New ("Initializing: Invalid function string missing_package. Needs package name as well." )
91
+ funcs := []string {"missing_package" }
92
+ err := TranslatableStrings ([]string {}, funcs , "" )
93
+ if err == nil || err .Error () != expected .Error () {
94
+ t .Fatalf ("expected %v, got %v" , expected , err )
95
+ }
96
+ }
You can’t perform that action at this time.
0 commit comments