mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-22 18:37:43 +00:00
Three tests each called newEnv, and newEnv built the binary, so the same binary was linked three times - about 17 seconds of the run, measured. A binary is read-only and there is nothing to isolate between tests; each test still gets its own directory and its own database. The package now builds it on the first test that needs one and removes it in TestMain. The suite goes from 39 seconds to 9. The three assertion blocks listed the same six queries, two or three times each, differing only in the counts expected - so renaming a table meant finding three places. They now share one list, with a flag for the uninstall's "all of them at zero". The reinstall check gets stronger on the way past: it was three of the six and is now all six. The per-call sql.Open in count and exec stays. It looks like waste and is not: the binary under test writes the same file, and a connection held open across a run of it is a second writer for nothing. The shared part is factored out; the opening is still per call, and the comment now says why.