File size: 1,159 Bytes
16cdcb7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | package subscriptiontestutils
import "github.com/openmeterio/openmeter/openmeter/subscription"
type TestPatch struct {
PatchValue any
PatchOperation subscription.PatchOperation
PatchPath subscription.SpecPath
ApplyToFn func(s *subscription.SubscriptionSpec, c subscription.ApplyContext) error
ValdiateFn func() error
}
var (
_ subscription.Patch = &TestPatch{}
_ subscription.ValuePatch[any] = &TestPatch{}
)
func (p *TestPatch) ApplyTo(s *subscription.SubscriptionSpec, c subscription.ApplyContext) error {
if p.ApplyToFn != nil {
return p.ApplyToFn(s, c)
}
return nil
}
func (p *TestPatch) Op() subscription.PatchOperation {
return p.PatchOperation
}
func (p *TestPatch) Path() subscription.SpecPath {
return p.PatchPath
}
func (p *TestPatch) Validate() error {
if p.ValdiateFn != nil {
return p.ValdiateFn()
}
return nil
}
func (p *TestPatch) MarshalJSON() ([]byte, error) {
panic("not implemented")
}
func (p *TestPatch) UnmarshalJSON(data []byte) error {
panic("not implemented")
}
func (p *TestPatch) Value() any {
return p.PatchValue
}
func (p *TestPatch) ValueAsAny() any {
return p.PatchValue
}
|