Blessed is the one who perseveres under trial; because, having stood the test; that person will receive the crown of life that the Lord has promised to those who love him.
Jesus was tempted before he began his mission(Mathew4) by Satan and not God(James1:13-15) the purpose ? to make Jesus fall.
How did Jesus resist temptation? by the words of God( which is the sword of the spirit) he overcame every temptation.
We face the same battle (Ephesians.6:12,1peter5:8) we have the same choices as Jesus has (Joshua24:15) we have been empowered by Gods word( which is the sword of the spirit) to resist Satan and be victorious on all challenges.
Peter was warned of the temptation ahead but failed to be conscious ,was over confident of his strength and under estimate the power of temptation. He failled woefully on the first trial.
if you think your standing strong be careful not to fall (1Corinthians10:12) keep watch and pray ceaselessly so that you will not give in to temptation, for the spirit may be willing but the body will be weak , for the spirit need a strong body to withstand the physical pressure.
Trials are a test of our faith to know our endurance and maturity in spirit. For our endurance has a chance to grow so also our spirit.
Romans8:28: when we have trials or test , we need sympathy , not condemnation.