diff --git a/mocks/loader.go b/mocks/loader.go index 8248cc4..3d557c3 100644 --- a/mocks/loader.go +++ b/mocks/loader.go @@ -173,7 +173,7 @@ func (l *Loader) loadFileStrategy(path string, def map[interface{}]interface{}) if err != nil { return nil, err } - return newFileReplyWithCode(filename, statusCode, headers), nil + return newFileReplyWithCode(filename, statusCode, headers) } func (l *Loader) loadConstantStrategy(path string, def map[interface{}]interface{}) (replyStrategy, error) { diff --git a/mocks/reply_strategy.go b/mocks/reply_strategy.go index c073780..5ba4c53 100644 --- a/mocks/reply_strategy.go +++ b/mocks/reply_strategy.go @@ -34,14 +34,17 @@ func unhandledRequestError(r *http.Request) []error { return []error{fmt.Errorf("unhandled request to mock:\n%s", requestContent)} } -func newFileReplyWithCode(filename string, statusCode int, headers map[string]string) replyStrategy { - content, _ := ioutil.ReadFile(filename) +func newFileReplyWithCode(filename string, statusCode int, headers map[string]string) (replyStrategy, error) { + content, err := ioutil.ReadFile(filename) + if err != nil { + return nil, err + } r := &constantReply{ replyBody: content, statusCode: statusCode, headers: headers, } - return r + return r, nil } func newConstantReplyWithCode(content []byte, statusCode int, headers map[string]string) replyStrategy {