Fix DeletedAt marshal and unmarshal, close #3693
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package tests_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
@@ -42,3 +43,14 @@ func TestSoftDelete(t *testing.T) {
|
||||
t.Errorf("Can't find permanently deleted record")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeletedAtUnMarshal(t *testing.T) {
|
||||
expected := &gorm.Model{}
|
||||
b, _ := json.Marshal(expected)
|
||||
|
||||
result := &gorm.Model{}
|
||||
_ = json.Unmarshal(b, result)
|
||||
if result.DeletedAt != expected.DeletedAt {
|
||||
t.Errorf("Failed, result.DeletedAt: %v is not same as expected.DeletedAt: %v", result.DeletedAt, expected.DeletedAt)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user