<div dir="ltr"><div>tl; dr: I need some help fixing our tests that are incorrectly not isolated from the real world.</div><div><br></div>So...<div><br></div><div>In investigating the bug with PatchValue and non pointer receivers, we realized that PatchValue calls AddCleanup. Which means that If you are doing:</div><div>func ... SetUpSuite() {</div><div>   s.PatchValue(&foo, safeFoo)</div><div>}</div><div><br></div><div>That PatchValue gets cleaned up in the first TearDownTest().Which means that the isolation you thought you were adding to the *Suite* is actually isolated only to the first test that gets run.</div><div><br></div><div>I have a branch of "juju/testing" that fixes it so AddCleanup can be called at any time. If it is called before SetUpTest(), then it adds a cleanup to the Suite stack, otherwise it adds it to the current Test stack.</div><div><br></div><div>But that breaks about 100 tests that weren't as isolated as they thought they were.</div><div><br></div><div>It also breaks a few tests that were Patching values before calling IsolationSuite.SetUpTest/Suite(), eg:</div><div>SetUpTest() {<br>  PatchValue()</div><div>  Base.SetUpTest()<br>}</div><div><br></div><div>My branch that starts working on this is at:</div><div> git@github.com:jameinel/juju unsafe-cleanups</div><div><br></div><div>One of the big examples of bad tests is "provider/ec2". 52 tests fail because they either try to read from <a href="http://cloud-images.ubunt.com">cloud-images.ubunt.com</a> directly, or because they try to read from test:/streams/v1/index.sjson but don't accept the signature on those files.</div><div><br></div><div><br></div><div>Is anyone able to help me tackle cleaning up our test suite?</div><div><br>Thanks,</div><div>John</div><div>=:-></div><div><br></div></div>