Skip to content

Commit

Permalink
[chore][cmd/mdatagen] Properly test bytes attribute type (open-teleme…
Browse files Browse the repository at this point in the history
…try#30106)

**Description:** 
Changes how attributes of type `bytes` are tested, as they were being
initialized incorrectly before.

**Link to tracking Issue:** Resolves open-telemetry#29923

**Testing:** 
Fake attribute added for testing:
```
attributes:
  # Added a fake attribute in a metadata.yaml file
  fake:
    description: "Fake attribute for testing"
    type: bytes
```
Test case generated by `cmd/mdatagen`:
```
                                       attrVal, ok = dp.Attributes().Get("fake")
                                       assert.True(t, ok)
                                       assert.EqualValues(t, []byte("fake-val"), attrVal.Bytes())
```
  • Loading branch information
crobert-1 authored Jan 5, 2024
1 parent 72dd3f8 commit 380a76e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/mdatagen/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (a attribute) TestValue() string {
case pcommon.ValueTypeSlice:
return fmt.Sprintf(`[]any{"%s-item1", "%s-item2"}`, a.FullName, a.FullName)
case pcommon.ValueTypeBytes:
return fmt.Sprintf(`bytes("%s-val")`, a.FullName)
return fmt.Sprintf(`[]byte("%s-val")`, a.FullName)
}
return ""
}
Expand Down

0 comments on commit 380a76e

Please sign in to comment.