fix lint errors
This commit is contained in:
parent
b08d025567
commit
3ceb355773
@ -9,6 +9,8 @@ import (
|
||||
"fmt"
|
||||
"decl/internal/data"
|
||||
"decl/internal/folio"
|
||||
"decl/internal/codec"
|
||||
"io"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -37,6 +39,22 @@ func (g *Generic[Value]) SetParsedURI(uri *url.URL) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Generic[Value]) Load(r io.Reader) (err error) {
|
||||
err = codec.NewYAMLDecoder(r).Decode(g)
|
||||
if err == nil {
|
||||
_, err = g.Read(context.Background())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (g *Generic[Value]) LoadYAML(yamlData string) (err error) {
|
||||
err = codec.NewYAMLStringDecoder(yamlData).Decode(g)
|
||||
if err == nil {
|
||||
_, err = g.Read(context.Background())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (g *Generic[Value]) Clone() data.Configuration {
|
||||
jsonGeneric, _ := json.Marshal(g)
|
||||
clone := NewGeneric[Value]()
|
||||
|
@ -27,10 +27,10 @@ values:
|
||||
bar: quuz
|
||||
`
|
||||
|
||||
testConfig := NewBlock()
|
||||
e := testConfig.LoadBlock(configBlockYaml)
|
||||
testConfig := NewGeneric[any]()
|
||||
|
||||
e := testConfig.LoadYAML(configBlockYaml)
|
||||
assert.Nil(t, e)
|
||||
assert.Equal(t, "foo", testConfig.Name)
|
||||
|
||||
jsonDoc, jsonErr := json.Marshal(testConfig)
|
||||
assert.Nil(t, jsonErr)
|
||||
@ -39,11 +39,9 @@ values:
|
||||
assert.Nil(t, schemaErr)
|
||||
}
|
||||
|
||||
/*
|
||||
func TestSchemaValidateSchema(t *testing.T) {
|
||||
s := NewSchema("document")
|
||||
assert.NotNil(t, s)
|
||||
s := NewSchema("document")
|
||||
assert.NotNil(t, s)
|
||||
|
||||
assert.Nil(t, s.ValidateSchema())
|
||||
}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user