Skip to content

Commit

Permalink
feat: log schema metadata (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard-henriquez authored Dec 12, 2023
1 parent e35512a commit fa1b327
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/annotator/annotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func getSchemaMetadata(schema []byte) schemaMetadata {
namespace := schemaContents.Get("self.namespace").String()
version := schemaContents.Get("self.version").String()
disableValidation := schemaContents.Get("disableValidation").Bool()
log.Debug().Msgf("🟡 vendor: %s, namespace: %s, version: %s, disableValidation: %t", vendor, namespace, version, disableValidation)
return schemaMetadata{
Vendor: vendor,
Namespace: namespace,
Expand Down
33 changes: 33 additions & 0 deletions pkg/annotator/annotator_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package annotator

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestGetSchemaMetadata(t *testing.T) {
testData := []struct {
name string
input []byte
expected schemaMetadata
}{
{
name: "Valid JSON",
input: []byte(`{"self":{"vendor":"testVendor","namespace":"testNamespace","version":"testVersion"},"disableValidation":true}`),
expected: schemaMetadata{
Vendor: "testVendor",
Namespace: "testNamespace",
Version: "testVersion",
DisableValidation: true,
},
},
}

for _, tc := range testData {
t.Run(tc.name, func(t *testing.T) {
result := getSchemaMetadata(tc.input)
assert.Equal(t, tc.expected, result)
})
}
}
1 change: 0 additions & 1 deletion pkg/annotator/test_annotator.go

This file was deleted.

0 comments on commit fa1b327

Please sign in to comment.