diff --git a/motivation.go b/motivation.go index 94436ffbeddd8ce2535b242457d6cb8bed1d600f..e06cd6a4f21070f46d4e65de0505645a8331407a 100644 --- a/motivation.go +++ b/motivation.go @@ -28,6 +28,11 @@ var ( ErrInvalidMotivation = errors.New("invalid motivation") ) +// String returns the motivation value as a string. +func (m Motivation) String() string { + return string(m) +} + // ParseMotivation parses a string to a Motivation value (case-insensitive). // Valid values: "unknown", "must", "should", "want". func ParseMotivation(str string) (Motivation, error) { diff --git a/motivation_test.go b/motivation_test.go index 27dc86df9b62e66d068941e04f453fb63a4aabe2..a1403d52689d01e3ad23c208572365792df0e053 100644 --- a/motivation_test.go +++ b/motivation_test.go @@ -52,3 +52,28 @@ func TestParseMotivation(t *testing.T) { }) } } + +func TestMotivation_String(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + value lunatask.Motivation + want string + }{ + {"unknown", lunatask.MotivationUnknown, "unknown"}, + {"must", lunatask.MotivationMust, "must"}, + {"should", lunatask.MotivationShould, "should"}, + {"want", lunatask.MotivationWant, "want"}, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + if got := tc.value.String(); got != tc.want { + t.Errorf("Motivation.String() = %q, want %q", got, tc.want) + } + }) + } +} diff --git a/relationship.go b/relationship.go index fc6fa7e0cc05248602d8d1db2b626ebeed9e2e95..292fcc6eaac5e9c6c292e5a99c7a8bdd7574c9ec 100644 --- a/relationship.go +++ b/relationship.go @@ -31,6 +31,11 @@ var ( ErrInvalidRelationshipStrength = errors.New("invalid relationship strength") ) +// String returns the relationship strength value as a string. +func (r RelationshipStrength) String() string { + return string(r) +} + // ParseRelationshipStrength parses a string to a RelationshipStrength value (case-insensitive). // Valid values: "family", "intimate-friends", "close-friends", "casual-friends", // "acquaintances", "business-contacts", "almost-strangers". diff --git a/status.go b/status.go index c3c861d72021d0e5442b59b6c0a19b918859965a..9a618384329b8be352bbddb66b3f32712076645d 100644 --- a/status.go +++ b/status.go @@ -29,6 +29,11 @@ var ( ErrInvalidTaskStatus = errors.New("invalid task status") ) +// String returns the task status value as a string. +func (s TaskStatus) String() string { + return string(s) +} + // ParseTaskStatus parses a string to a TaskStatus value (case-insensitive). // Valid values: "later", "next", "started", "in-progress", "waiting", "completed". func ParseTaskStatus(str string) (TaskStatus, error) {