| 1 |
/* |
| 2 |
Copyright 2013-2014 Canonical Ltd. |
| 3 |
|
| 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. |
| 7 |
|
| 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. |
| 12 |
|
| 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/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
// Package testing implements a couple of Ids that are useful |
| 18 |
// for testing things that use identifier. |
| 19 |
package testing |
| 20 |
|
| 21 |
// SettableIdentifier is an Id that lets you set the value of the identifier. |
| 22 |
// |
| 23 |
// By default the identifier's value is "<Settable>", so it's visible |
| 24 |
// if you're misusing it. |
| 25 |
type SettableIdentifier struct { |
| 26 |
value string |
| 27 |
} |
| 28 |
|
| 29 |
// Settable is the constructor for SettableIdentifier. |
| 30 |
func Settable() *SettableIdentifier { |
| 31 |
return &SettableIdentifier{"<Settable>"} |
| 32 |
} |
| 33 |
|
| 34 |
// Set is the method you use to set the identifier. |
| 35 |
func (sid *SettableIdentifier) Set(value string) { |
| 36 |
sid.value = value |
| 37 |
} |
| 38 |
|
| 39 |
// String returns the string you set. |
| 40 |
func (sid *SettableIdentifier) String() string { |
| 41 |
return sid.value |
| 42 |
} |
| 43 |
|
| 44 |
// FailingIdentifier is an Id that always fails to generate. |
| 45 |
type FailingIdentifier struct{} |
| 46 |
|
| 47 |
// Failing is the constructor for FailingIdentifier. |
| 48 |
func Failing() *FailingIdentifier { |
| 49 |
return &FailingIdentifier{} |
| 50 |
} |
| 51 |
|
| 52 |
// String returns "<Failing>". |
| 53 |
// |
| 54 |
// The purpose of this is to make it easy to spot if you're using it |
| 55 |
// by accident. |
| 56 |
func (*FailingIdentifier) String() string { |
| 57 |
return "<Failing>" |
| 58 |
} |