jx/internal/folio/mock_configuration_test.go
Matthew Rich 8feb7b8d56
Some checks failed
Lint / golangci-lint (push) Failing after 10m1s
Declarative Tests / test (push) Failing after 14s
add support of import search paths [doublejynx/jx#7]
2024-10-16 10:26:42 -07:00

106 lines
2.7 KiB
Go

// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package folio
import (
"context"
_ "gopkg.in/yaml.v3"
"encoding/json"
_ "fmt"
"decl/internal/data"
"decl/internal/codec"
"io"
)
type MockConfiguration struct {
InjectURI func() string `json:"-" yaml:"-"`
InjectType func() string `json:"-" yaml:"-"`
InjectResolveId func(ctx context.Context) string `json:"-" yaml:"-"`
InjectValidate func() error `json:"-" yaml:"-"`
InjectJSON func() ([]byte, error) `json:"-" yaml:"-"`
InjectYAML func() ([]byte, error) `json:"-" yaml:"-"`
InjectPB func() ([]byte, error) `json:"-" yaml:"-"`
InjectGenerate func(w io.Writer) (error) `json:"-" yaml:"-"`
InjectLoadString func(string, codec.Format) (error) `json:"-" yaml:"-"`
InjectLoad func([]byte, codec.Format) (error) `json:"-" yaml:"-"`
InjectLoadReader func(io.ReadCloser, codec.Format) (error) `json:"-" yaml:"-"`
InjectRead func(context.Context) ([]byte, error) `json:"-" yaml:"-"`
InjectGetValue func(key string) (any, error) `json:"-" yaml:"-"`
InjectHas func(key string) (bool) `json:"-" yaml:"-"`
}
func (m *MockConfiguration) Clone() data.Configuration {
return nil
}
func (m *MockConfiguration) SetURI(uri string) error {
return nil
}
func (m *MockConfiguration) SetParsedURI(uri data.URIParser) error {
return nil
}
func (m *MockConfiguration) URI() string {
return m.InjectURI()
}
func (m *MockConfiguration) ResolveId(ctx context.Context) string {
return m.InjectResolveId(ctx)
}
func (m *MockConfiguration) JSON() ([]byte, error) {
return m.InjectJSON()
}
func (m *MockConfiguration) YAML() ([]byte, error) {
return m.InjectYAML()
}
func (m *MockConfiguration) PB() ([]byte, error) {
return m.InjectPB()
}
func (m *MockConfiguration) Generate(w io.Writer) (error) {
return m.InjectGenerate(w)
}
func (m *MockConfiguration) LoadString(docData string, format codec.Format) (error) {
return m.InjectLoadString(docData, format)
}
func (m *MockConfiguration) Load(docData []byte, format codec.Format) (error) {
return m.InjectLoad(docData, format)
}
func (m *MockConfiguration) LoadReader(r io.ReadCloser, format codec.Format) (error) {
return m.InjectLoadReader(r, format)
}
func (m *MockConfiguration) Read(ctx context.Context) ([]byte, error) {
return m.InjectRead(ctx)
}
func (m *MockConfiguration) Validate() error {
return m.InjectValidate()
}
func (m *MockConfiguration) Type() string {
return m.InjectType()
}
func (m *MockConfiguration) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, m); err != nil {
return err
}
return nil
}
func (m *MockConfiguration) GetValue(key string) (any, error) {
return m.InjectGetValue(key)
}
func (m *MockConfiguration) Has(key string) (bool) {
return m.InjectHas(key)
}