Update tests for PR 39727
Update tests for PR 39727

Also reduce the complexity of some of the mocking by adding the cachedir
to the global state.__opts__.

saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt