"The most wise, righteous, and gracious God doth oftentimes leave for a season His own children to manifold temptations, and the corruptions of their own hearts, to chastise them for their former sins, or to discover unto them the hidden strength of corruption, and the deceitfulness of their hearts, that they may be humbled; and to raise them up to a more close and constant dependance for their support upon Himself, and to make them more watchful against all future occasions of sin, and for sundry other just and holy ends."
Westminster Confession of Faith, Chapter 5.5
One of the things I love about Scripture and biblical Christianity is how true to life it is. I mean, it isn't this pale, shallow shadow that tries to paste a smiley face over the worst of situations. Instead it spits on both its hands and gets right down in the pit with you and helps you out.
That is one of the reasons we should take joy in trials. They help us to sort out if we really believe all this "stuff." Falling into sin, or coming close to it is no fun. But it does give you practical experience of the lovingkindness and tender mercies of God, not to mention his infinite wisdom and patience. The One who watches Israel does not sleep, and He will not let his elect fall away finally and forever into sin.