Maybe. Using illegal drugs can be considered misconduct and your employer can fire you for it.
However, EDD (California Employment Development Department) has an exception for drug dependence. If you enter a rehabilitation program (this can include medically-supervised outpatient programs), you may be able to collect unemployment benefits.
You may not think you have a drug problem, but consider this: you knew your employer might randomly test you, but you used drugs anyway, and it got you fired. To me, that sounds like a problem.
Please understand that this is a general discussion of legal principles by a California lawyer and does not create an attorney/client relationship. It's impossible to give detailed, accurate advice based on a few sentences on a website (and you shouldn't provide too much specific information about your legal matter on a public forum like this site, anyway). You should always seek advice from an attorney licensed in your jurisdiction who can give you an informed opinion after reviewing all of the relevant information.
You may be ineligible for unemployment benefits as a result of the failed drug test pursuant to California UI Code Section 1256.4. However, you should nonetheless submit your benefits request and go through the process to force a final determination on the issue based on the reasons you provide.
The response given is not intended to create, nor does it create an ongoing duty to respond to questions. The response does not form an attorney-client relationship, nor is it intended to be anything other than the educated opinion of the author. It should not be relied upon as legal advice. The response given is based upon the limited facts provided by the person asking the question. To the extent additional or different facts exist, the response might possibly change.