setting createdAt and updatedAt in bolt and inmem
parent
fa132d19a7
commit
4057183dac
|
@ -222,6 +222,10 @@ func (c *Client) CreateVariable(ctx context.Context, variable *platform.Variable
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
now := c.Now()
|
||||||
|
variable.CreatedAt = now
|
||||||
|
variable.UpdatedAt = now
|
||||||
|
|
||||||
if pe := c.putVariable(ctx, tx, variable); pe != nil {
|
if pe := c.putVariable(ctx, tx, variable); pe != nil {
|
||||||
return &platform.Error{
|
return &platform.Error{
|
||||||
Op: op,
|
Op: op,
|
||||||
|
|
|
@ -103,6 +103,9 @@ func (s *Service) CreateVariable(ctx context.Context, m *platform.Variable) erro
|
||||||
Err: err,
|
Err: err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
now := s.Now()
|
||||||
|
m.CreatedAt = now
|
||||||
|
m.UpdatedAt = now
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ const (
|
||||||
|
|
||||||
var oldFakeDate = time.Date(2002, 8, 5, 2, 2, 3, 0, time.UTC)
|
var oldFakeDate = time.Date(2002, 8, 5, 2, 2, 3, 0, time.UTC)
|
||||||
var fakeDate = time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)
|
var fakeDate = time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)
|
||||||
var fakeGenerator = mock.TimeGenerator{FakeValue: fakeDate}
|
var fakeGenerator = mock.TimeGenerator{FakeValue:fakeDate}
|
||||||
|
|
||||||
var variableCmpOptions = cmp.Options{
|
var variableCmpOptions = cmp.Options{
|
||||||
cmp.Comparer(func(x, y []byte) bool {
|
cmp.Comparer(func(x, y []byte) bool {
|
||||||
|
@ -167,10 +167,6 @@ func CreateVariable(init func(VariableFields, *testing.T) (platform.VariableServ
|
||||||
Type: "constant",
|
Type: "constant",
|
||||||
Values: platform.VariableConstantValues{"b"},
|
Values: platform.VariableConstantValues{"b"},
|
||||||
},
|
},
|
||||||
CRUDLog: platform.CRUDLog{
|
|
||||||
CreatedAt: fakeDate,
|
|
||||||
UpdatedAt: fakeDate,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -270,10 +266,10 @@ func FindVariableByID(init func(VariableFields, *testing.T) (platform.VariableSe
|
||||||
Type: "constant",
|
Type: "constant",
|
||||||
Values: platform.VariableConstantValues{},
|
Values: platform.VariableConstantValues{},
|
||||||
},
|
},
|
||||||
CRUDLog: platform.CRUDLog{
|
//CRUDLog: platform.CRUDLog{
|
||||||
CreatedAt: fakeDate,
|
// CreatedAt: fakeDate,
|
||||||
UpdatedAt: fakeDate,
|
// UpdatedAt: fakeDate,
|
||||||
},
|
//},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(idB),
|
ID: MustIDBase16(idB),
|
||||||
|
@ -582,7 +578,7 @@ func UpdateVariable(init func(VariableFields, *testing.T) (platform.VariableServ
|
||||||
},
|
},
|
||||||
CRUDLog: platform.CRUDLog{
|
CRUDLog: platform.CRUDLog{
|
||||||
CreatedAt: oldFakeDate,
|
CreatedAt: oldFakeDate,
|
||||||
UpdatedAt: oldFakeDate,
|
UpdatedAt: fakeDate,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -595,7 +591,7 @@ func UpdateVariable(init func(VariableFields, *testing.T) (platform.VariableServ
|
||||||
},
|
},
|
||||||
CRUDLog: platform.CRUDLog{
|
CRUDLog: platform.CRUDLog{
|
||||||
CreatedAt: oldFakeDate,
|
CreatedAt: oldFakeDate,
|
||||||
UpdatedAt: oldFakeDate,
|
UpdatedAt: fakeDate,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -619,7 +615,7 @@ func UpdateVariable(init func(VariableFields, *testing.T) (platform.VariableServ
|
||||||
},
|
},
|
||||||
CRUDLog: platform.CRUDLog{
|
CRUDLog: platform.CRUDLog{
|
||||||
CreatedAt: oldFakeDate,
|
CreatedAt: oldFakeDate,
|
||||||
UpdatedAt: oldFakeDate,
|
UpdatedAt: fakeDate,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -766,6 +762,10 @@ func DeleteVariable(init func(VariableFields, *testing.T) (platform.VariableServ
|
||||||
Type: "constant",
|
Type: "constant",
|
||||||
Values: platform.VariableConstantValues{},
|
Values: platform.VariableConstantValues{},
|
||||||
},
|
},
|
||||||
|
CRUDLog: platform.CRUDLog{
|
||||||
|
CreatedAt: oldFakeDate,
|
||||||
|
UpdatedAt: oldFakeDate,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue