Skip to content

Commit

Permalink
backend: more serialize object integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bojand committed Aug 31, 2023
1 parent dde5877 commit 7f58284
Show file tree
Hide file tree
Showing 3 changed files with 777 additions and 189 deletions.
1 change: 1 addition & 0 deletions backend/pkg/serde/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type TroubleshootingReport struct {
}

type SerializeInput struct {
Topic string
Key RecordPayloadInput
Value RecordPayloadInput
}
Expand Down
15 changes: 13 additions & 2 deletions backend/pkg/serde/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ func (s *Service) SerializeRecord(input SerializeInput) (*SerializeOutput, error
sr := SerializeOutput{}

// key
if input.Topic != "" {
input.Key.Options = append(input.Key.Options, WithTopic(input.Topic))
}

keyTS := make([]TroubleshootingReport, 0)
found := false
for _, serde := range s.SerDes {
Expand All @@ -188,11 +192,12 @@ func (s *Service) SerializeRecord(input SerializeInput) (*SerializeOutput, error
} else {
keySerResult.Encoding = serde.Name()
keySerResult.Payload = bytes
keySerResult.Troubleshooting = keyTS
}
}
}

keySerResult.Troubleshooting = keyTS

sr.Key = &keySerResult

if !found {
Expand All @@ -203,6 +208,11 @@ func (s *Service) SerializeRecord(input SerializeInput) (*SerializeOutput, error
return &sr, err
}

// value
if input.Topic != "" {
input.Value.Options = append(input.Value.Options, WithTopic(input.Topic))
}

valueTS := make([]TroubleshootingReport, 0)
found = false
for _, serde := range s.SerDes {
Expand All @@ -218,11 +228,12 @@ func (s *Service) SerializeRecord(input SerializeInput) (*SerializeOutput, error
} else {
valueSerResult.Encoding = serde.Name()
valueSerResult.Payload = bytes
valueSerResult.Troubleshooting = valueTS
}
}
}

valueSerResult.Troubleshooting = valueTS

sr.Value = &valueSerResult

if !found {
Expand Down
Loading

0 comments on commit 7f58284

Please sign in to comment.