My question involves criminal law for the state of: Texas
Ok, I'll try to make a long story short. First off, back in June my apartment complex changed locks on everyone without notification, this resulted in them finding pets that werent allowed. So they searched my apartment and found marijuana, then they called the cops to continue the search. After I got home from work that day I had to face the music and was evicted that day, also the cops came in and told me to rat on someone, I chose not to. About a month and a half later, the cops were outside my work waiting for me to arrest me for that marijuana charge back in June. My court date has been continually pushed back as random things keep happening (i.e. the death of the judge the day before my hearing) and is scheduled for the end of Nov.
Well I just made everything much worse as I was driving a couple hours back home and was pulled over for an expired inspection (which was an amazing spot by the police officer as we were both going 70mph in opposite directions). He pulled me out and seemed cool, as we chatted. Then he asked if he could search my car because he thought I looked fidgety when he pulled me over. I went against my better judgement and allowed him to search because he said if I was honest he would be cool with me. So before he searched I told him he would find a couple of roaches in the center console. He found those, then promptly put me in hand cuffs and took me to jail (happy veterans day to me!).
So now I have two outstanding possession charges both of which I feel are unjustified (although it goes without saying I am obviously biased).
Did the cops have the right to search on either of these cases?
How bad am I going to get hammered?

