Skip to content

Commit

Permalink
Always sync and dump cache on parse (#55)
Browse files Browse the repository at this point in the history
* Always sync and dump cache on parse

* Fix annotations parsing and update tests

* Fix parser test and update index tests
  • Loading branch information
yury-palyanitsa authored Nov 25, 2024
1 parent 6d7f2fd commit 39fbe2e
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 207 deletions.
5 changes: 2 additions & 3 deletions metadata/collector/annotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ func Test_AnnotationCollector(t *testing.T) {
fn: func(e raml.Shape) any {
c := NewAnnotationsCollector()
obj := e.(*raml.ObjectShape)
c.Collect(obj)
return c.annotations
return c.Collect(obj)
},
want: map[metadata.GJsonPath]metadata.Annotations{".": {
Cti: "cti.vendor.app.test.v1.0",
Expand All @@ -52,7 +51,7 @@ func Test_AnnotationCollector(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got := tc.fn(tc.shape)
require.Equal(t, got, tc.want)
require.Equal(t, tc.want, got)
})
}
}
4 changes: 3 additions & 1 deletion metadata/collector/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/acronis/go-raml"
)

const MetadataPrefix = "cti."

type AnnotationsCollector struct {
annotations map[metadata.GJsonPath]metadata.Annotations
}
Expand Down Expand Up @@ -78,7 +80,7 @@ func (c *AnnotationsCollector) collectAnnotations(ctx string, s *raml.BaseShape)
filtered := make([]*raml.DomainExtension, 0)
for pair := s.CustomDomainProperties.Oldest(); pair != nil; pair = pair.Next() {
annotation := pair.Value
if strings.HasPrefix(annotation.Name, "metadata.") {
if strings.HasPrefix(annotation.Name, MetadataPrefix) {
filtered = append(filtered, annotation)
}
}
Expand Down
Loading

0 comments on commit 39fbe2e

Please sign in to comment.