2
Copyright 2013-2014 Canonical Ltd.
4
This program is free software: you can redistribute it and/or modify it
5
under the terms of the GNU General Public License version 3, as published
6
by the Free Software Foundation.
8
This program is distributed in the hope that it will be useful, but
9
WITHOUT ANY WARRANTY; without even the implied warranties of
10
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along
14
with this program. If not, see <http://www.gnu.org/licenses/>.
17
// Package testing implements a couple of Ids that are useful
18
// for testing things that use whoopsie/identifier.
23
// SettableIdentifier is an Id that lets you set the value of the identifier.
25
// By default the identifier's value is "<Settable>", so it's visible
26
// if you're misusing it.
27
type SettableIdentifier struct {
31
// Settable is the constructor for SettableIdentifier.
32
func Settable() *SettableIdentifier {
33
return &SettableIdentifier{"<Settable>"}
36
// Set is the method you use to set the identifier.
37
func (sid *SettableIdentifier) Set(value string) {
41
// Generate does nothing.
42
func (sid *SettableIdentifier) Generate() error {
46
// String returns the string you set.
47
func (sid *SettableIdentifier) String() string {
51
// FailingIdentifier is an Id that always fails to generate.
52
type FailingIdentifier struct{}
54
// Failing is the constructor for FailingIdentifier.
55
func Failing() *FailingIdentifier {
56
return &FailingIdentifier{}
59
// Generate fails with an ubiquitous error.
60
func (*FailingIdentifier) Generate() error {
61
return errors.New("lp0 on fire")
64
// String returns "<Failing>".
66
// The purpose of this is to make it easy to spot if you're using it
68
func (*FailingIdentifier) String() string {