coveralls.io and error handling in Golang - go

I wrote a library for Instagram API and tell coveralls.io to check my repository
but coveralls.io tell me that all of the error handlers in my source code isn't Good. see this
How can I handle errors perfectly and coveralls.io say it's good :smile:
sorry for my English

I think it's trying to tell you that your tests are not covering that path. It means that the tests you wrote are probably testing only the "happy path" and not going into those error handling branches.

Related

SagePay Server Integration

I'm integrating SagePay Server and am stuck at step 4 here: https://developer-eu.elavon.com/docs/opayo-server/taking-payments
I get this error: Server error 5006: Unable to redirect to Vendor's web site. The Vendor failed to provide a RedirectionURL.
I know there are quite a lot of suggestions for this error out there. That it basically means there is something wrong with your code on the Notification URL.
I know it is completing the previous steps fine (I get the correct response parameters), I have made sure Opayo's IPs are allowed, the MD5 signatures match.
I think the problem is how I am "Responding to the Notification Post".
I am doing a standard WebRequest to send our RedirectUrl to SagePay - but the link here - SagePay RedirectURL failure - suggests it doesn't need that. Rather I should just "write to the simple Response object." The trouble is, I don't know what they mean by that.
Any help / experience with this, much appreciated.
Jon
I hope this answer isn't too late to be useful to you.
You're suffering from the main issue I've always had with Opayo (formerly SagePay) - namely that their integration guides for developers are terrible.
As the Opayo Server integration method is identical to the old SagePay version, I found it helpful to follow the much more in-depth instructions from before they rebranded. You can find those instructions here:
https://www.opayo.co.uk/file/12246/download-document/SERVER_Integration_and_Protocol_Guidelines_010814.pdf
In answer to your specific question, you can refer to page 68 of the above PDF guide. RE: You acknowledge receipt of the Notification POST, quote, "This is the plain text response part of the POST originated by the Server in the step above. Encoding must be as Name=Value fields separated by carriage-return linefeeds (CRLF)."
Literally, your script just has to print or echo something along the lines of:
Status=OK\r\n
StatusDetail=Hashes match - proceeding\r\n
RedirectURL=https://www.yoursite.com/endpointpage/
Or the equivalent for errors, aborts, etc.
Bear in mind that any output not formatted like the above will break the foldback process, so you must supress any errors or warnings your script might generate (ideally capturing them in a log or some other way).
Opayo give you basically no help in bugfixing, so if you continue to encounter errors you pretty much have to work in the dark.

Getting started with Open Liberty: 404

I'm trying to follow the guide here - https://openliberty.io/guides/getting-started.html. I'm on the Building and running the application step. I ran "mvn liberty:run" and Open Liberty started without any errors but when I go to http://localhost:9080/system/properties I get the error below.
Error 404:
com.ibm.ws.webcontainer.servlet.exception.NoTargetForURIException: No
target servlet configured for uri: /system/properties
Any suggestions?
At the end of each guide in the "Nice Work! Where to next?" section, each guide has link:
Raise an issue to share feedback
which I would recommend for these kind of questions as you're likely going to get a quicker response if you open an issue directly against the code you're using.

cy.visit crashes without meaningfull messages

I'm new to cypress and I want to create tests for a rather oldfashioned website which is unfortunatelly not available on the internet.
When I perform a simple call to the website cypress crashes:
cy.visit('http://10.0.0.6:8080/dmc')
The message I get within the chromium instance is: "Whoops, there is no test to run. Choose a test to run from the desktop application."
Shortly before I get this message, I see some messages in red in the left chromium task-runner-pannel (sorry for not knowing the correct term). But the timespan is too short to read it.
So my questions are, any ideas why cypress is crashing? I know this may gonna be a tough one since the website is not accessable.
Can I find these "red-messages" somewhere else? eg a logfile?
BR,
Richard

Codeigniter hiding errors from libraries. Why?

So I has a small problem as I outlined here.
I have made a new question because this is more general and will perhaps help others.
So essentially, I integrated the Facebook SDK Into Codeigniter as a library.
The SDK requires Json and Curl.
In the base_facebook.php file there is the following code:
if (!function_exists('curl_init')) {
throw new Exception('Facebook needs the CURL PHP extension.');
}
if (!function_exists('json_decode')) {
throw new Exception('Facebook needs the JSON PHP extension.');
}
If these functions are not available I expect an error to be fired to tell me such. Then I can install the correct packages and continue.
What actually happened is that even when I had error reporting set to E_ALL a blank page was returned.
This made it impossible to debug and after lots of playing I worked out it was because CURL was not installed on my server.
My question is why does codeigniter show blank pages rather than library based exceptions?
Furthermore even if there is an exception in a library why does the rest of the page not continue executing.
Essentially CI is seemingly making the use of exceptions worthless..
COuld anyone advise?
THanks
My question is why does codeigniter show blank pages rather than library based exceptions?
Most likely because display_errors is set to “off”.
While this is recommended for a production environment (web site users are not supposed to see internal error messages – it might give them info about internals, that they are not supposed to have) – it’s not very helpful while developing, where you as the developer want to be informed about what went wrong.
So check if CI has a “debug” setting for this, or if it’s maybe already set to off in your PHP configuration.
(Maybe CI or your config are set up in a way that errors are logged to a file instead. Also recommended for production; while developing, you’d have to keep an eye on this file then.)
Furthermore even if there is an exception in a library why does the rest of the page not continue executing.
Because that’s how exceptions are supposed to work – if they are not being caught when they reach the “top level” of your app, they cause a fatal error, and scripts die when those occur.
Familiarize yourself with the concept of try { … } catch(…) { … } to handle exceptions that might occur in script flow.
(Actually, it’s kinda surprising you don’t know all this already, if you’re working with an advanced PHP framework …)

Selenium RC test passes when it should fail on verifyTrue(selenium.isTextPresent("string"))

I have a suite of Selenium tests that I created in the Selenium IDE and ported over to Java. In several tests I use the Java equivalent of the verifyTextPresent command to confirm some text on the page (verifyTrue(selenium.isTextPresent())).
I found an spelling error in the text on the page when running the test from the IDE, but the error was not caught when running the test via Selenium RC/TestNG. Here's an example of the code that I have and the text that is causing the problem (spelling error in bold):
Text:
Please correct the errors indicated below.
You need to add a least one restriction.
IDE:
verifyTextPresent | Please correct the errors indicated below.
verifyTextPresent | You need to add at least one restriction.
Java:
verifyTrue(selenium.isTextPresent("Please correct the errors indicated below."));
verifyTrue(selenium.isTextPresent("You need to add at least one restriction."));
Since both versions of the test have the correct text, why is the Selenium RC version not catching the error? Has anyone else had this problem?
The reason why this happens is that the test continues to run after the call to verifyTrue(). Verifications in Selenium catch the exceptions that would be thrown by a failed verification, as opposed to an assertion which throws an exception and causes the test to fail. Because verifications catch exceptions instead of throwing them, the test passes.
At the end of the test, the method checkForVerificationErrors() needs to be called to see if any of the verifications failed. If the method is not called, any verification errors will be ignored and the test will still pass (absent any other problems).
A discussion on the Selenium Google Group about the error itself is here. A discussion about the various verifications vs. assertions is here.
I had a similar problem... My workaround is to use assertTrue() instead of verifyTrue(). I hope it works for you to.

Resources