marshal database value to byte slice
This commit is contained in:
+2
-2
@@ -129,9 +129,9 @@ func (t *ClockTime) UnmarshalGQL(value any) error {
|
||||
}
|
||||
|
||||
// Value implements the database/sql/driver.Valuer interface for ClockTime.
|
||||
// Marshals the ClockTime to a time.Time for database storage.
|
||||
// Marshals the ClockTime to a byte slice for database storage.
|
||||
func (t ClockTime) Value() (driver.Value, error) {
|
||||
return t.Time(), nil
|
||||
return []byte(t.String()), nil
|
||||
}
|
||||
|
||||
// Scan implements the database/sql.Scanner interface for ClockTime.
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package clocktime
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_Comparison(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
time1 := NewClockTime(10, 30, 0)
|
||||
time2 := NewClockTime(11, 0, 0)
|
||||
time3 := NewClockTime(10, 30, 0)
|
||||
|
||||
assert.True(time1.Before(time2))
|
||||
assert.False(time1.After(time2))
|
||||
assert.False(time1.Equal(time2))
|
||||
assert.True(time1.Equal(time3))
|
||||
}
|
||||
Reference in New Issue
Block a user