package fixture
import "sigs.k8s.io/structured-merge-diff/internal/fixture"
Index ¶
- func FixTabsOrDie(in typed.YAMLObject) typed.YAMLObject
- type Apply
- type ForceApply
- type Operation
- type State
- func (s *State) Apply(obj typed.YAMLObject, version fieldpath.APIVersion, manager string, force bool) error
- func (s *State) CompareLive(obj typed.YAMLObject) (*typed.Comparison, error)
- func (s *State) Update(obj typed.YAMLObject, version fieldpath.APIVersion, manager string) error
- type TestCase
- func (tc TestCase) Bench(parser typed.ParseableType) error
- func (tc TestCase) BenchWithConverter(parser typed.ParseableType, converter merge.Converter) error
- func (tc TestCase) Test(parser typed.ParseableType) error
- func (tc TestCase) TestWithConverter(parser typed.ParseableType, converter merge.Converter) error
- type Update
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 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 Operation ¶
type Operation interface {
// contains filtered or unexported methods
}
Operation is a step that will run when building a table-driven test.
type State ¶
type State struct { Live *typed.TypedValue Parser typed.ParseableType 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.
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) CompareLive ¶
func (s *State) CompareLive(obj typed.YAMLObject) (*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
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 // 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 }
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 ¶
func (tc TestCase) Bench(parser typed.ParseableType) error
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) Test ¶
func (tc TestCase) Test(parser typed.ParseableType) error
Test runs the test-case using the given parser and a dummy converter.
func (TestCase) TestWithConverter ¶
TestWithConverter runs the test-case using the given parser and converter.
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.
Source Files ¶
state.go
- Version
- v1.0.2 (latest)
- Published
- Dec 24, 2019
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 1 month ago –
Tools for package owners.