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

Commit

Permalink
fix: OptionalString String() default
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Oct 29, 2021
1 parent eb0d046 commit 5861089
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func (p *OptionalString) UnmarshalJSON(input []byte) error {

func (p OptionalString) String() string {
if p.value == nil {
return ""
return "default"
}
return *p.value
}
Expand Down
4 changes: 2 additions & 2 deletions types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ func TestOptionalString(t *testing.T) {
if val := defaultOptionalString.WithDefault(""); val != "" {
t.Errorf("optional string should have been empty, got %s", val)
}
if val := defaultOptionalString.String(); val != "" {
t.Fatalf("default optional string should be an empty string, got %s", val)
if val := defaultOptionalString.String(); val != "default" {
t.Fatalf("default optional string should be the 'default' string, got %s", val)
}
if val := defaultOptionalString.WithDefault("foo"); val != "foo" {
t.Errorf("optional string should have been foo, got %s", val)
Expand Down

0 comments on commit 5861089

Please sign in to comment.