20 Then the LORD said, "The outcry against Sodom and Gomorrah is so great and their sin so grievous 21 that I will go down and see if what they have done is as bad as the outcry that has reached me. If not, I will know."22 The men turned away and went toward Sodom, but Abraham remained standing before the LORD. [e] 23 Then Abraham approached him and said: "Will you sweep away the righteous with the wicked? 24 What if there are fifty righteous people in the city? Will you really sweep it away and not spare [f] the place for the sake of the fifty righteous people in it? 25 Far be it from you to do such a thingto kill the righteous with the wicked, treating the righteous and the wicked alike. Far be it from you! Will not the Judge [g Genesis 18:25 Or Ruler ] of all the earth do right?"
26 The LORD said, "If I find fifty righteous people in the city of Sodom, I will spare the whole place for their sake."
27 Then Abraham spoke up again: "Now that I have been so bold as to speak to the Lord, though I am nothing but dust and ashes, 28 what if the number of the righteous is five less than fifty? Will you destroy the whole city because of five people?"
"If I find forty-five there," he said, "I will not destroy it."29 Once again he spoke to him, "What if only forty are found there?"
He said, "For the sake of forty, I will not do it."30 Then he said, "May the Lord not be angry, but let me speak. What if only thirty can be found there?"
He answered, "I will not do it if I find thirty there."31 Abraham said, "Now that I have been so bold as to speak to the Lord, what if only twenty can be found there?"
He said, "For the sake of twenty, I will not destroy it."32 Then he said, "May the Lord not be angry, but let me speak just once more. What if only ten can be found there?"
He answered, "For the sake of ten, I will not destroy it."
Exodus:
32:11 And Moses besought the LORD his God, and said, LORD, why doth thy wrath wax hot against thy people, which thou hast brought forth out of the land of Egypt with great power, and with a mighty hand?
[snip]
32:14 And the LORD repented of the evil which he thought to do unto his people.
Your conclusion is not being reached within the referenced text or as a result of the referenced text.
And God did destroy Sodom and Gomorrah...The "exercise" was for the benefit of Abraham, not all-knowing and supremely righteous God (the Perfect Judge).