diff --git a/pkg/policy/policytest/spec.go b/pkg/policy/policytest/spec.go index ad6f679..914f3f5 100644 --- a/pkg/policy/policytest/spec.go +++ b/pkg/policy/policytest/spec.go @@ -2,6 +2,7 @@ package policytest import ( "github.com/ipld/go-ipld-prime" + "github.com/ucan-wg/go-ucan/pkg/args" "github.com/ucan-wg/go-ucan/pkg/policy" "github.com/ucan-wg/go-ucan/pkg/policy/literal" @@ -10,9 +11,8 @@ import ( // EmptyPolicy provides a Policy with no statements. var EmptyPolicy = policy.Policy{} -// ExampleValidationPolicy provides a instantiated SpecPolicy containing the -// statements that are included in the second code block of the [Validation] -// section of the delegation specification. +// SpecPolicy provides a valid Policy containing the statements that are included +// in the second code block of the [Validation] section of the delegation specification. // // [Validation]: https://github.com/ucan-wg/delegation/tree/v1_ipld#validation var SpecPolicy = policy.MustConstruct( @@ -24,8 +24,8 @@ var SpecPolicy = policy.MustConstruct( // specification has been finished/merged. // SpecValidArguments provides valid, instantiated Arguments containing -// the key/value pairs that are included in portion of the the second code -// block of the [Validation] section of the delegation specification. +// the key/value pairs that are included in portion of the second code block +// of the [Validation] section of the delegation specification. // // [Validation]: https://github.com/ucan-wg/delegation/tree/v1_ipld#validation var SpecValidArguments = args.NewBuilder(). @@ -41,8 +41,8 @@ var SpecValidArguments = args.NewBuilder(). var specValidArgumentsIPLD = mustIPLD(SpecValidArguments) // SpecInvalidArguments provides invalid, instantiated Arguments containing -// the key/value pairs that are included in portion of the the second code -// block of the [Validation] section of the delegation specification. +// the key/value pairs that are included in portion of the second code block +// of the [Validation] section of the delegation specification. // // [Validation]: https://github.com/ucan-wg/delegation/tree/v1_ipld#validation var SpecInvalidArguments = args.NewBuilder(). diff --git a/pkg/policy/selector/parsing.go b/pkg/policy/selector/parsing.go index 13be0a1..fef0439 100644 --- a/pkg/policy/selector/parsing.go +++ b/pkg/policy/selector/parsing.go @@ -173,37 +173,37 @@ func tokenize(str string) []string { return toks } -type parseerr struct { +type parseErr struct { msg string src string col int tok string } -func (p parseerr) Name() string { +func (p parseErr) Name() string { return "ParseError" } -func (p parseerr) Message() string { +func (p parseErr) Message() string { return p.msg } -func (p parseerr) Column() int { +func (p parseErr) Column() int { return p.col } -func (p parseerr) Error() string { +func (p parseErr) Error() string { return p.msg } -func (p parseerr) Source() string { +func (p parseErr) Source() string { return p.src } -func (p parseerr) Token() string { +func (p parseErr) Token() string { return p.tok } func newParseError(message string, source string, column int, token string) error { - return parseerr{message, source, column, token} + return parseErr{message, source, column, token} } diff --git a/pkg/policy/selector/selector.go b/pkg/policy/selector/selector.go index 249cd44..4d17909 100644 --- a/pkg/policy/selector/selector.go +++ b/pkg/policy/selector/selector.go @@ -19,7 +19,7 @@ type Selector []segment // Select perform the selection described by the selector on the input IPLD DAG. // Select can return: // - exactly one matched IPLD node -// - a resolutionerr error if not being able to resolve to a node +// - a resolutionErr error if not being able to resolve to a node // - nil and no errors, if the selector couldn't match on an optional segment (with ?). func (s Selector) Select(subject ipld.Node) (ipld.Node, error) { return resolve(s, subject, nil) @@ -316,27 +316,27 @@ func kindString(n datamodel.Node) string { return n.Kind().String() } -type resolutionerr struct { +type resolutionErr struct { msg string at []string } -func (r resolutionerr) Name() string { +func (r resolutionErr) Name() string { return "ResolutionError" } -func (r resolutionerr) Message() string { +func (r resolutionErr) Message() string { return fmt.Sprintf("can not resolve path: .%s", strings.Join(r.at, ".")) } -func (r resolutionerr) At() []string { +func (r resolutionErr) At() []string { return r.at } -func (r resolutionerr) Error() string { +func (r resolutionErr) Error() string { return r.Message() } func newResolutionError(message string, at []string) error { - return resolutionerr{message, at} + return resolutionErr{message, at} } diff --git a/pkg/policy/selector/selector_test.go b/pkg/policy/selector/selector_test.go index fdd18ec..9883db8 100644 --- a/pkg/policy/selector/selector_test.go +++ b/pkg/policy/selector/selector_test.go @@ -133,7 +133,7 @@ func TestSelect(t *testing.T) { require.Error(t, err) require.Empty(t, res) - require.ErrorAs(t, err, &resolutionerr{}, "error should be a resolution error") + require.ErrorAs(t, err, &resolutionErr{}, "error should be a resolution error") }) t.Run("optional not exists", func(t *testing.T) { @@ -351,7 +351,7 @@ func FuzzParseAndSelect(f *testing.F) { // look for panic() _, err = sel.Select(node) - if err != nil && !errors.As(err, &resolutionerr{}) { + if err != nil && !errors.As(err, &resolutionErr{}) { // not normal, we should only have resolution errors t.Fatal(err) }