Whether you are tested the first time in court will depend upon the judge and the prosecutor. Assume you will be tested and satrted getting clean now. Then stay clean. Speak to your lawyer about your situation for fuyrtehr guidance and advice.
Many factors determine if you will be required to drop on the next court date. Consult with your attorney ASAP. It is early in the case several approaches will be available to you, but start preparing now by anticipating the drop. That means don't use. If this is a difficulty then consider other treatment alternatives.
This answer/response is based on the information provided in the question asked and requires a much more complete context than is available in this public forum. Please do NOT use this answer/response to say or do anything regarding your situation. BEFORE you say or do anything consult with an experienced Federal and/or state criminal defense attorney in your jurisdiction who will listen to you and your concerns.