Documentation ¶
Index ¶
- Variables
- func FixTabsOrDie(in typed.YAMLObject) typed.YAMLObject
- type Apply
- type ApplyObject
- type ChangeParser
- type ExtractApply
- type ExtractApplyObject
- type ForceApply
- type ForceApplyObject
- type Operation
- type Parser
- type SameVersionParser
- type State
- func (s *State) Apply(obj typed.YAMLObject, version fieldpath.APIVersion, manager string, force bool) error
- func (s *State) ApplyObject(tv *typed.TypedValue, version fieldpath.APIVersion, manager string, force bool) error
- func (s *State) CompareLive(obj typed.YAMLObject, version fieldpath.APIVersion) (*typed.Comparison, error)
- func (s *State) Update(obj typed.YAMLObject, version fieldpath.APIVersion, manager string) error
- func (s *State) UpdateObject(tv *typed.TypedValue, version fieldpath.APIVersion, manager string) error
- type TestCase
- func (tc TestCase) Bench(parser Parser) error
- func (tc TestCase) BenchWithConverter(parser Parser, converter merge.Converter) error
- func (tc TestCase) PreprocessOperations(parser Parser) error
- func (tc TestCase) Test(parser Parser) error
- func (tc TestCase) TestWithConverter(parser Parser, converter merge.Converter) error
- type Update
- type UpdateObject
Constants ¶
This section is empty.
Variables ¶
var DeducedParser = SameVersionParser{ T: typed.DeducedParseableType, }
DeducedParser is a parser that is deduced no matter what the version specified.
Functions ¶
func FixTabsOrDie ¶
func FixTabsOrDie(in typed.YAMLObject) typed.YAMLObject
FixTabsOrDie counts the number of tab characters preceding the first line in the given yaml object. It removes that many tabs from every line. It panics (it's a test funtion) if some line has fewer tabs than the first line.
The purpose of this is to make it easier to read tests.
Types ¶
type Apply ¶
type Apply struct { Manager string APIVersion fieldpath.APIVersion Object typed.YAMLObject Conflicts merge.Conflicts }
Apply is a type of operation. It is a non-forced apply run by a manager with a given object. Since non-forced apply operation can conflict, the user can specify the expected conflicts. If conflicts don't match, an error will occur.
type ApplyObject ¶
type ApplyObject struct { Manager string APIVersion fieldpath.APIVersion Object *typed.TypedValue Conflicts merge.Conflicts }
type ChangeParser ¶
ChangeParser is a type of operation. It simulates making changes a schema without versioning the schema. This can be used to test the behavior of making backward compatible schema changes, e.g. setting "elementRelationship: atomic" on an existing struct. It also may be used to ensure that backward incompatible changes are detected appropriately.
type ExtractApply ¶
type ExtractApply struct { Manager string APIVersion fieldpath.APIVersion Object typed.YAMLObject }
ExtractApply is a type of operation. It simulates extracting an object the state based on the manager you have applied with, merging the apply object with that extracted object and reapplying that.
type ExtractApplyObject ¶
type ExtractApplyObject struct { Manager string APIVersion fieldpath.APIVersion Object *typed.TypedValue }
type ForceApply ¶
type ForceApply struct { Manager string APIVersion fieldpath.APIVersion Object typed.YAMLObject }
ForceApply is a type of operation. It is a forced-apply run by a manager with a given object. Any error will be returned.
type ForceApplyObject ¶
type ForceApplyObject struct { Manager string APIVersion fieldpath.APIVersion Object *typed.TypedValue }
ForceApplyObject is a type of operation. It is a forced-apply run by a manager with a given object. Any error will be returned.
type Operation ¶
type Operation interface {
// contains filtered or unexported methods
}
Operation is a step that will run when building a table-driven test.
type Parser ¶
type Parser interface {
Type(string) typed.ParseableType
}
For the sake of tests, a parser is something that can retrieve a ParseableType.
type SameVersionParser ¶
type SameVersionParser struct {
T typed.ParseableType
}
SameVersionParser can be used if all the versions are actually using the same type.
func (SameVersionParser) Type ¶
func (p SameVersionParser) Type(_ string) typed.ParseableType
type State ¶
type State struct { Live *typed.TypedValue Parser Parser Managers fieldpath.ManagedFields Updater *merge.Updater }
State of the current test in terms of live object. One can check at any time that Live and Managers match the expectations.
The parser will look for the type by using the APIVersion of the object it's trying to parse. If trying to parse a "v1" object, a corresponding "v1" type should exist in the schema. If all the versions should map to the same type, or to a DeducedParseableType, one can use the SameVersionParser or the DeducedParser types defined in this package.
func (*State) Apply ¶
func (s *State) Apply(obj typed.YAMLObject, version fieldpath.APIVersion, manager string, force bool) error
Apply the passed in object to the current state
func (*State) ApplyObject ¶
func (s *State) ApplyObject(tv *typed.TypedValue, version fieldpath.APIVersion, manager string, force bool) error
func (*State) CompareLive ¶
func (s *State) CompareLive(obj typed.YAMLObject, version fieldpath.APIVersion) (*typed.Comparison, error)
CompareLive takes a YAML string and returns the comparison with the current live object or an error.
func (*State) Update ¶
func (s *State) Update(obj typed.YAMLObject, version fieldpath.APIVersion, manager string) error
Update the current state with the passed in object
func (*State) UpdateObject ¶
func (s *State) UpdateObject(tv *typed.TypedValue, version fieldpath.APIVersion, manager string) error
type TestCase ¶
type TestCase struct { // Ops is the list of operations to run sequentially Ops []Operation // Object, if not empty, is the object as it's expected to // be after all the operations are run. Object typed.YAMLObject // APIVersion should be set if the object is non-empty and // describes the version of the object to compare to. APIVersion fieldpath.APIVersion // Managed, if not nil, is the ManagedFields as expected // after all operations are run. Managed fieldpath.ManagedFields // Set to true if the test case needs the union behavior enabled. RequiresUnions bool // IgnoredFields containing the set to ignore for every version IgnoredFields map[fieldpath.APIVersion]*fieldpath.Set }
TestCase is the list of operations that need to be run, as well as the object/managedfields as they are supposed to look like after all the operations have been successfully performed. If Object/Managed is not specified, then the comparison is not performed (any object or managed field will pass). Any error (conflicts aside) happen while running the operation, that error will be returned right away.
func (TestCase) Bench ¶
Bench runs the test-case using the given parser and a dummy converter, but doesn't check exit conditions--see the comment for BenchWithConverter.
func (TestCase) BenchWithConverter ¶
BenchWithConverter runs the test-case using the given parser and converter, but doesn't do any comparison operations aftewards; you should probably run TestWithConverter once and reset the benchmark, to make sure the test case actually passes..
func (TestCase) PreprocessOperations ¶
Preprocess all the operations by parsing the yaml before-hand.
type Update ¶
type Update struct { Manager string APIVersion fieldpath.APIVersion Object typed.YAMLObject }
Update is a type of operation. It is a controller type of update. Errors are passed along.
type UpdateObject ¶
type UpdateObject struct { Manager string APIVersion fieldpath.APIVersion Object *typed.TypedValue }
UpdateObject is a type of operation. It is a controller type of update. Errors are passed along.