Skip to content
This repository was archived by the owner on Jan 18, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions registry/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package registry
import (
"bytes"
"context"
"encoding/binary"
"fmt"
"io"
"net"
Expand Down Expand Up @@ -121,6 +122,13 @@ type SchemaInfo struct {
Metadata SchemaMetadata
}

// IDBytes returns 4 bytes that represent the schema ID.
func (s SchemaInfo) IDBytes() []byte {
result := make([]byte, 4)
binary.BigEndian.PutUint32(result, uint32(s.ID))
return result
}

// SchemaMetadata represents the schema metadata.
type SchemaMetadata struct {
Properties map[string]string
Expand Down
10 changes: 10 additions & 0 deletions registry/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ func TestNewClient_UrlError(t *testing.T) {
assert.Error(t, err)
}

func TestSchemaInfo_IDBytes(t *testing.T) {
schemaInfo := registry.SchemaInfo{
ID: 123456789,
}

idBytes := schemaInfo.IDBytes()

assert.Equal(t, []byte{7, 91, 205, 21}, idBytes)
}

func TestClient_PopulatesError(t *testing.T) {
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/vnd.schemaregistry.v1+json")
Expand Down