Documentation
¶
Overview ¶
Package testsupport holds Ginkgo helpers shared by the suites of several packages. Nothing outside a _test.go file imports it.
It exists for assertions that more than one suite needs and that mean something different per platform. Two things live here today, and they are unlike each other:
The mode assertions. fft writes its config, its credentials fallback and its update cache owner-only; four suites check that; and on Windows none of those checks can hold, because Windows has no POSIX mode bits. A file's security there is an ACL and os.Stat reports a synthetic 0666 for every regular file, so there is nothing to assert. ExpectOwnerOnly* therefore skip the calling spec on Windows, loudly and with a reason, rather than assert a guarantee the platform does not make. What that means for fft's secrets on Windows is written down in the README, under the keychain section — a skipped security assertion must not be the only record that the guarantee is weaker.
Making a directory unwritable. This one is not a mode-bits problem and does not skip anywhere. The spec it serves pins atomicfile's contract — a save that cannot complete leaves the previous file intact — which every platform is meant to keep. Windows only needs a different lever to pull: a deny ACE instead of a mode bit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpectOwnerOnlyDir ¶
func ExpectOwnerOnlyDir(path string)
ExpectOwnerOnlyDir asserts that path is a directory no user but its owner can enter — mode 0700. On Windows it skips the calling spec; see the package doc.
func ExpectOwnerOnlyFile ¶
func ExpectOwnerOnlyFile(path string)
ExpectOwnerOnlyFile asserts that path is a file no user but its owner can read — mode 0600. On Windows it skips the calling spec; see the package doc.
func MakeUnwritableDir ¶
func MakeUnwritableDir(dir string)
MakeUnwritableDir takes away the right to create files in dir for the rest of the spec, so that a spec can watch the code under test fail to write there. The right is restored on cleanup, or the suite's own temp-directory teardown would be unable to remove dir.
How the right is taken away differs per platform — a mode bit off on Unix, a deny ACE on Windows — so this then proves it worked, by trying the very thing the code under test is about to try. A platform where the lever quietly did nothing would still fail the calling spec, because the save it expects to fail would succeed; but it would fail it as though atomicfile had regressed, which is the wrong culprit and a long afternoon. A helper whose whole purpose is to make a write fail should be the one to say when it could not.
Types ¶
This section is empty.