File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ func newExtractor(functionsToCheck []string) (*state, error) {
9292 // Functions must be of the form "package.function"
9393 t2 := strings .Split (t , "." )
9494 if len (t2 ) < 2 {
95- return nil , errors .Wrap ( nil , fmt . Sprintf ( "Invalid function string %s. Needs package name as well. " , t ) )
95+ return nil , errors .Errorf ( "invalid function string %s. Needs package name as well" , t )
9696 }
9797 f := funcType {
9898 pack : t2 [0 ],
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package extract
1818
1919import (
2020 "encoding/json"
21+ "errors"
2122 "io/ioutil"
2223 "os"
2324 "path/filepath"
@@ -84,3 +85,12 @@ func TestExtract(t *testing.T) {
8485 }
8586
8687}
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