Psa 139:23 Search me, O God, and know my heart! Try me and know my thoughts!
Psa 139:24 And see if there be any grievous way in me, and lead me in the way everlasting!
Psalms 139 is often used as a prooftext passage for God’s omniscience of all future events. King David is writing and describes God’s relationship with him. The passage ends in an interesting passage in which King David invites God to test him further. King David invites God to “search” him and then to “know his heart”. This is re-enforced by the next phrase “try me” in order to “know my thoughts”. Verse 24 ties this to “seeing” if there is any grievous thing in King David.
The interesting thing about this text is that it is a callback to the introduction to the Psalm. King David has stated God has searched an known him (v1). In King David’s eyes, God knows because God tests. God’s current knowledge is about what God has previously tested. God’s familiarity comes from interaction. This is not eternal knowledge of all things, but gained knowledge.
King David’s view is not that God knows the entire future meticulously, but that God can gain new information from further testing.