Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
interfaces: add TestSecurityBackend #943
Conversation
niemeyer
reviewed
Apr 14, 2016
| + // SnapInfo is a copy of the snapInfo argument to a particular call to Setup | ||
| + SnapInfo *snap.Info | ||
| + // DeveloperMode is a copy of the developerMode argument to a particular call to Setup | ||
| + DeveloperMode bool |
niemeyer
Apr 14, 2016
Contributor
We've used DevMode in the state, and the term seems like a nice short hand to the concept. We should probably even change dev-mode there to devmode, and have the command line flag as --devmode too.
niemeyer
reviewed
Apr 14, 2016
| +} | ||
| + | ||
| +// SetupCall stores details about calls to TestSecurityBackend.Setup | ||
| +type SetupCall struct { |
niemeyer
Apr 14, 2016
Contributor
TestSetupCall so we're not polluting the public package namespace much.
niemeyer
reviewed
Apr 14, 2016
| + | ||
| +// Setup records information about the call and calls the setup callback if one is defined. | ||
| +func (b *TestSecurityBackend) Setup(snapInfo *snap.Info, developerMode bool, repo *Repository) error { | ||
| + b.SetupCalls = append(b.SetupCalls, SetupCall{SnapInfo: snapInfo, DeveloperMode: developerMode}) |
niemeyer
Apr 14, 2016
Contributor
Actually, maybe we should just drop this.. we have SetupCallback already. If the test wants to store the calls, just set up a trivial handler for it?
zyga
Apr 14, 2016
Contributor
Well, most tests do just that but I want to introduce faults. I'd rather keep it since it doesn't prevent anyone from doing other stuff and just ignoring this.
EDIT: sorry, my comment makes no sense.
- I rely heavily on the convenience of recording calls
- The callbacks are for planned fault testing that I'm not doing yet
Let's please keep it. I can change that after release, this will save me some time from changing tests.
niemeyer
reviewed
Apr 14, 2016
| + | ||
| +// Remove records information about the call and calls the remove callback if one is defined | ||
| +func (b *TestSecurityBackend) Remove(snapName string) error { | ||
| + b.RemoveCalls = append(b.RemoveCalls, snapName) |
zyga commentedApr 14, 2016
This patch adds a security backend that is intended for testing. As with
the test interface it is public because it has to be used in other
packages.
Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com