Skip to content

Commit 9d983b7

Browse files
committed
add marshal yaml func test
1 parent 2baa05e commit 9d983b7

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

internal/pkg/utils/utils_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,3 +502,45 @@ func TestConvertToBase64PatchedServers(t *testing.T) {
502502
})
503503
}
504504
}
505+
506+
func TestBase64Bytes_MarshalYAML(t *testing.T) {
507+
tests := []struct {
508+
name string
509+
input Base64Bytes
510+
expected interface{}
511+
}{
512+
{
513+
name: "empty bytes",
514+
input: Base64Bytes{},
515+
expected: "",
516+
},
517+
{
518+
name: "nil bytes",
519+
input: Base64Bytes(nil),
520+
expected: "",
521+
},
522+
{
523+
name: "simple text",
524+
input: Base64Bytes("test"),
525+
expected: "dGVzdA==",
526+
},
527+
{
528+
name: "special characters",
529+
input: Base64Bytes("test@#$%"),
530+
expected: "dGVzdEAjJCU=",
531+
},
532+
}
533+
534+
for _, tt := range tests {
535+
t.Run(tt.name, func(t *testing.T) {
536+
result, err := tt.input.MarshalYAML()
537+
if err != nil {
538+
t.Errorf("MarshalYAML() error = %v", err)
539+
return
540+
}
541+
if result != tt.expected {
542+
t.Errorf("MarshalYAML() = %v, want %v", result, tt.expected)
543+
}
544+
})
545+
}
546+
}

0 commit comments

Comments
 (0)