setting createdAt and updatedAt in bolt and inmem

pull/14173/head
lisale0 2019-06-19 13:10:50 -07:00
parent fa132d19a7
commit 4057183dac
3 changed files with 19 additions and 12 deletions

View File

@ -222,6 +222,10 @@ func (c *Client) CreateVariable(ctx context.Context, variable *platform.Variable
return err
}
now := c.Now()
variable.CreatedAt = now
variable.UpdatedAt = now
if pe := c.putVariable(ctx, tx, variable); pe != nil {
return &platform.Error{
Op: op,

View File

@ -103,6 +103,9 @@ func (s *Service) CreateVariable(ctx context.Context, m *platform.Variable) erro
Err: err,
}
}
now := s.Now()
m.CreatedAt = now
m.UpdatedAt = now
return nil
}

View File

@ -21,7 +21,7 @@ const (
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 fakeGenerator = mock.TimeGenerator{FakeValue: fakeDate}
var fakeGenerator = mock.TimeGenerator{FakeValue:fakeDate}
var variableCmpOptions = cmp.Options{
cmp.Comparer(func(x, y []byte) bool {
@ -167,10 +167,6 @@ func CreateVariable(init func(VariableFields, *testing.T) (platform.VariableServ
Type: "constant",
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",
Values: platform.VariableConstantValues{},
},
CRUDLog: platform.CRUDLog{
CreatedAt: fakeDate,
UpdatedAt: fakeDate,
},
//CRUDLog: platform.CRUDLog{
// CreatedAt: fakeDate,
// UpdatedAt: fakeDate,
//},
},
{
ID: MustIDBase16(idB),
@ -582,7 +578,7 @@ func UpdateVariable(init func(VariableFields, *testing.T) (platform.VariableServ
},
CRUDLog: platform.CRUDLog{
CreatedAt: oldFakeDate,
UpdatedAt: oldFakeDate,
UpdatedAt: fakeDate,
},
},
{
@ -595,7 +591,7 @@ func UpdateVariable(init func(VariableFields, *testing.T) (platform.VariableServ
},
CRUDLog: platform.CRUDLog{
CreatedAt: oldFakeDate,
UpdatedAt: oldFakeDate,
UpdatedAt: fakeDate,
},
},
},
@ -619,7 +615,7 @@ func UpdateVariable(init func(VariableFields, *testing.T) (platform.VariableServ
},
CRUDLog: platform.CRUDLog{
CreatedAt: oldFakeDate,
UpdatedAt: oldFakeDate,
UpdatedAt: fakeDate,
},
},
{
@ -766,6 +762,10 @@ func DeleteVariable(init func(VariableFields, *testing.T) (platform.VariableServ
Type: "constant",
Values: platform.VariableConstantValues{},
},
CRUDLog: platform.CRUDLog{
CreatedAt: oldFakeDate,
UpdatedAt: oldFakeDate,
},
},
},
},