Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit 5861089

Browse files
committed
fix: OptionalString String() default
#153 (review)
1 parent eb0d046 commit 5861089

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ func (p *OptionalString) UnmarshalJSON(input []byte) error {
358358

359359
func (p OptionalString) String() string {
360360
if p.value == nil {
361-
return ""
361+
return "default"
362362
}
363363
return *p.value
364364
}

types_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ func TestOptionalString(t *testing.T) {
409409
if val := defaultOptionalString.WithDefault(""); val != "" {
410410
t.Errorf("optional string should have been empty, got %s", val)
411411
}
412-
if val := defaultOptionalString.String(); val != "" {
413-
t.Fatalf("default optional string should be an empty string, got %s", val)
412+
if val := defaultOptionalString.String(); val != "default" {
413+
t.Fatalf("default optional string should be the 'default' string, got %s", val)
414414
}
415415
if val := defaultOptionalString.WithDefault("foo"); val != "foo" {
416416
t.Errorf("optional string should have been foo, got %s", val)

0 commit comments

Comments
 (0)