> This. If there is a government contract involved, even if you are not working directly on it, you will have to pee in a cup.
This is not correct. When I held a clearance (which I don't anymore and won't again) the Department of Defense never made me take a drug test. I did, however, work for a publicly-traded government contractor that made me take one both times that they hired me as a matter of course. I worked for three other such defense contractors that were happy to have me without such a test.
I thought it was just a mild inconvenience until I developed a sinus infection and started taking pseudoephedrine and diphenhydramine two days before I was scheduled to take the test. Because these OTC drugs can cause false positives for methamphetamine and marijuana respectively (depending upon whether the test is reagent-based or GCMS) I had to quit taking them and suffer through two days of an upper respiratory infection to pass the test and placate some HR drone in Alabama.
I'm sure that there's a policy or exemption process for this situation but the same company also almost pushed my start date because their background verification service couldn't verify my past employment _at the same company_, i.e. their onboarding team was grossly incompetent. I decided not to chance it as I didn't want to go weeks without a paycheck while they sorted out a false positive. Needless to say I don't waste my time dealing with this class of employers any longer.
Not that this helps you now, but I believe if the reagent test fails, they immediately GCMS the sample to both determine the quantitative amount of substance in question, as well as rule out false positives, so you probably would have been fine (for the diphenhydramine at least).
The drugs you took outside your work hours don't know they have to exit your bloodstream the hour you start working. Perhaps not all occupations need such tests, but at least people driving vehicles and operating heavy equipment should be made sure to have their system clear while at work.
The tests usually don't have granularity to know if you're intoxicated during work hours precisely. Most test for metabolites that either aren't intoxicating or intoxicating in far higher levels than detection cutoff.