proxy-wasm-go-sdk icon indicating copy to clipboard operation
proxy-wasm-go-sdk copied to clipboard

test framework: Mock DispatchHttpCall to return error

Open rodrigovc opened this issue 2 years ago • 0 comments

I am doing unit tests for my filter with DispatchHttp, something like this:


_, err = proxywasm.DispatchHttpCall(ctx.clusterName, headers, body, nil, ctx.timeout, ctx.callback)
	if err != nil {
		proxywasm.LogCriticalf("big error: %v", err)
		proxywasm.ResumeHttpRequest()
		return types.ActionContinue
	}

I don't know of a way to mock the DispatchHttpCall method in order to return an error so we can cover this part of the code.

Is there any way of doing this?

rodrigovc avatar Mar 02 '22 20:03 rodrigovc