Detailed changes
@@ -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) {
@@ -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)
+ }
+ })
+ }
+}
@@ -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".
@@ -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) {