MCPcopy Create free account
hub / github.com/copernet/copernicus / check

Method check

logic/lscript/lscript_test.go:207–242  ·  view source on GitHub ↗
(err error, scriptErrorString string)

Source from the content-addressed store, hash-verified

205}
206
207func (sec *scriptErrChecker) check(err error, scriptErrorString string) error {
208 var (
209 actualErr string
210 actualErrUpper string
211 perr errcode.ProjectError
212 )
213 if err == nil {
214 actualErr = "OK"
215 actualErrUpper = "OK"
216 } else {
217 var ok bool
218 if perr, ok = err.(errcode.ProjectError); !ok {
219 err = fmt.Errorf("Error in converting err to ProjectErr")
220 return err
221 }
222 actualErr = sec.errtable[perr.Code-errcode.ScriptErrorBase]
223
224 if strings.HasPrefix(actualErr, "ScriptErr") {
225 actualErrUpper = strings.TrimPrefix(actualErr, "ScriptErr")
226 } else {
227 err = fmt.Errorf("ScriptErr should begin with \"ScriptErr\"")
228 return err
229 }
230 actualErrUpper = strings.TrimPrefix(actualErrUpper, "Invalid")
231 actualErrUpper = strings.TrimPrefix(actualErrUpper, "Sig")
232 actualErrUpper = strings.ToUpper(actualErrUpper)
233 }
234 scriptErrorStringUpper := strings.TrimPrefix(scriptErrorString, "INVALID")
235 scriptErrorStringUpper = strings.TrimPrefix(scriptErrorStringUpper, "SIG")
236 scriptErrorStringUpper = strings.Replace(scriptErrorStringUpper, "_", "", -1)
237 if actualErrUpper != scriptErrorStringUpper {
238 err = fmt.Errorf("expect: %v err: %v", scriptErrorString, actualErr)
239 return err
240 }
241 return nil
242}
243
244func doScriptJSONTest(t *testing.T, itest []interface{}, sec scriptErrChecker) (err error) {
245 if len(itest) == 0 {

Callers 1

doScriptJSONTestFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected