From 380a76e137516a33d80ea3ebad37024f6c9a82c7 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Fri, 5 Jan 2024 14:18:44 -0800 Subject: [PATCH] [chore][cmd/mdatagen] Properly test bytes attribute type (#30106) **Description:** Changes how attributes of type `bytes` are tested, as they were being initialized incorrectly before. **Link to tracking Issue:** Resolves #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()) ``` --- cmd/mdatagen/loader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/mdatagen/loader.go b/cmd/mdatagen/loader.go index 701c008138be..322d273e33a0 100644 --- a/cmd/mdatagen/loader.go +++ b/cmd/mdatagen/loader.go @@ -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 "" }