Complete integer schema version consumer readiness
This commit is contained in:
@@ -83,7 +83,7 @@ type ObjectBinding struct {
|
||||
Options map[string]any `yaml:"options"`
|
||||
}
|
||||
|
||||
// NotariusConfig demonstrates string versions and dynamic catalog options.
|
||||
// NotariusConfig demonstrates string-backed versions and dynamic catalog options.
|
||||
type NotariusConfig struct {
|
||||
Version string `yaml:"version"`
|
||||
Bindings []ObjectBinding `yaml:"bindings"`
|
||||
@@ -93,7 +93,7 @@ type NotariusConfig struct {
|
||||
func LoadNotarius(path string) (*configkit.Result[NotariusConfig], error) {
|
||||
return configkit.Load(configkit.File(path), configkit.Options[NotariusConfig]{
|
||||
Definition: configkit.Definition[NotariusConfig]{
|
||||
Version: &configkit.VersionRule{Path: configkit.Keys("version"), Check: requireVersion("v1")},
|
||||
Version: &configkit.VersionRule{Path: configkit.Keys("version"), Check: requireVersion("4")},
|
||||
Validate: validateNotarius,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -26,7 +26,7 @@ func Example_notarius() {
|
||||
result, err := consumers.LoadNotarius(fixture("notarius", "config.yml"))
|
||||
window, ok := consumers.NotariusWindow(result.Config, 0)
|
||||
fmt.Println(result.Config.Version, result.Config.Bindings[0].Object, window, ok, err)
|
||||
// Output: v1 summary 12 true <nil>
|
||||
// Output: 4 summary 12 true <nil>
|
||||
}
|
||||
|
||||
func Example_weatherReporter() {
|
||||
@@ -100,6 +100,10 @@ func TestMaintainedConsumerFixturesPreserveDomainOutcomes(t *testing.T) {
|
||||
if _, ok := notarius.Config.Bindings[0].Options["window_units"].(int64); !ok {
|
||||
t.Fatalf("dynamic integer type = %T", notarius.Config.Bindings[0].Options["window_units"])
|
||||
}
|
||||
integerNotarius, err := consumers.LoadNotarius(fixture("notarius", "integer-version.yml"))
|
||||
if err != nil || integerNotarius.Config.Version != notarius.Config.Version || integerNotarius.Config.Version != "4" {
|
||||
t.Fatalf("Notarius version forms = %#v / %#v, %v", notarius.Config, integerNotarius, err)
|
||||
}
|
||||
|
||||
weather, err := consumers.LoadWeather(configkit.File(fixture("weather", "config.yml")))
|
||||
if err != nil || weather.Config.Reports["daily"].Modules[1].Options.Sections[0] != "short_term" {
|
||||
@@ -124,10 +128,21 @@ func TestMigrationFixturesFailWithStableCodesAndPaths(t *testing.T) {
|
||||
path string
|
||||
}{
|
||||
{
|
||||
name: "unsupported integer schema version",
|
||||
load: func() error { _, err := consumers.LoadNotarius(fixture("notarius", "integer-version.yml")); return err },
|
||||
name: "unsupported application version",
|
||||
load: func() error {
|
||||
_, err := consumers.LoadNotarius(fixture("notarius", "unsupported-version.yml"))
|
||||
return err
|
||||
},
|
||||
code: configkit.CodeVersionError, path: "/version",
|
||||
},
|
||||
{
|
||||
name: "non-integer numeric version",
|
||||
load: func() error {
|
||||
_, err := consumers.LoadNotarius(fixture("notarius", "noninteger-version.yml"))
|
||||
return err
|
||||
},
|
||||
code: configkit.CodeVersionType, path: "/version",
|
||||
},
|
||||
{
|
||||
name: "module shorthand",
|
||||
load: func() error {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version: v1
|
||||
version: "4"
|
||||
bindings:
|
||||
- object: summary
|
||||
options:
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
version: 1
|
||||
bindings: []
|
||||
version: 4
|
||||
bindings:
|
||||
- object: summary
|
||||
options:
|
||||
window_units: 12
|
||||
format: markdown
|
||||
|
||||
2
examples/consumers/testdata/notarius/noninteger-version.yml
vendored
Normal file
2
examples/consumers/testdata/notarius/noninteger-version.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
version: 4.0
|
||||
bindings: []
|
||||
2
examples/consumers/testdata/notarius/unsupported-version.yml
vendored
Normal file
2
examples/consumers/testdata/notarius/unsupported-version.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
version: 5
|
||||
bindings: []
|
||||
Reference in New Issue
Block a user