49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
||
|
|
||
|
package folio
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
_ "gopkg.in/yaml.v3"
|
||
|
"decl/internal/codec"
|
||
|
"decl/internal/data"
|
||
|
"io"
|
||
|
"net/url"
|
||
|
"path/filepath"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
func RegisterConfigurationMocks() {
|
||
|
TestConfigurationTypes.Register([]string{"generic"}, func(u *url.URL) data.Configuration {
|
||
|
q := NewQuuzConfiguration()
|
||
|
q.Name = filepath.Join(u.Hostname(), u.Path)
|
||
|
return q
|
||
|
})
|
||
|
}
|
||
|
|
||
|
type MockQuuz struct {
|
||
|
*MockConfiguration `json:"-" yaml:"-"`
|
||
|
Name string `json:"name" yaml:"name"`
|
||
|
Value string `json:"value" yaml:"value"`
|
||
|
}
|
||
|
|
||
|
func NewMockConfiguration(typename string) *MockConfiguration {
|
||
|
return &MockConfiguration {
|
||
|
InjectType: func() string { return typename },
|
||
|
InjectResolveId: func(ctx context.Context) string { return "bar" },
|
||
|
InjectLoadString: func(string, codec.Format) (error) { return nil },
|
||
|
InjectLoad: func([]byte, codec.Format) (error) { return nil },
|
||
|
InjectLoadReader: func(io.ReadCloser, codec.Format) (error) { return nil },
|
||
|
InjectValidate: func() error { return nil },
|
||
|
InjectRead: func(context.Context) ([]byte, error) { return nil, nil },
|
||
|
InjectGetValue: func(key string) (any, error) { return nil, nil },
|
||
|
InjectURI: func() string { return fmt.Sprintf("%s://bar", typename) },
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func NewQuuzConfiguration() *MockQuuz {
|
||
|
q := &MockQuuz {}
|
||
|
q.MockConfiguration = NewMockConfiguration("generic")
|
||
|
return q
|
||
|
}
|