mirror of
https://github.com/hashicorp/vault.git
synced 2026-02-18 18:38:08 -05:00
some small version test changes (#13310)
This commit is contained in:
parent
5e5642c872
commit
cec23b238c
2 changed files with 6 additions and 5 deletions
|
|
@ -1047,7 +1047,7 @@ func NewCore(conf *CoreConfig) (*Core, error) {
|
|||
return c, nil
|
||||
}
|
||||
|
||||
// HandleVersionTimeStamps stores the current version at the current time to
|
||||
// handleVersionTimeStamps stores the current version at the current time to
|
||||
// storage, and then loads all versions and upgrade timestamps out from storage.
|
||||
func (c *Core) handleVersionTimeStamps(ctx context.Context) error {
|
||||
currentTime := time.Now()
|
||||
|
|
|
|||
|
|
@ -32,8 +32,9 @@ func TestGetOldestVersion(t *testing.T) {
|
|||
c, _, _ := TestCoreUnsealed(t)
|
||||
upgradeTimePlusEpsilon := time.Now()
|
||||
|
||||
c.storeVersionTimestamp(context.Background(), "1.9.1", upgradeTimePlusEpsilon.Add(-4*time.Hour))
|
||||
c.storeVersionTimestamp(context.Background(), "1.9.2", upgradeTimePlusEpsilon.Add(2*time.Hour))
|
||||
// 1.6.2 is stored before 1.6.1, so even though it is a higher number, it should be returned.
|
||||
c.storeVersionTimestamp(context.Background(), "1.6.2", upgradeTimePlusEpsilon.Add(-4*time.Hour))
|
||||
c.storeVersionTimestamp(context.Background(), "1.6.1", upgradeTimePlusEpsilon.Add(2*time.Hour))
|
||||
c.loadVersionTimestamps(c.activeContext)
|
||||
if len(c.versionTimestamps) != 3 {
|
||||
t.Fatalf("expected 3 entries in timestamps map after refresh, found: %d", len(c.versionTimestamps))
|
||||
|
|
@ -42,8 +43,8 @@ func TestGetOldestVersion(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v != "1.9.1" {
|
||||
t.Fatalf("expected 1.9.1, found: %s", v)
|
||||
if v != "1.6.2" {
|
||||
t.Fatalf("expected 1.6.2, found: %s", v)
|
||||
}
|
||||
if tm.Before(upgradeTimePlusEpsilon.Add(-6*time.Hour)) || tm.After(upgradeTimePlusEpsilon.Add(-2*time.Hour)) {
|
||||
t.Fatalf("incorrect upgrade time logged: %v", tm)
|
||||
|
|
|
|||
Loading…
Reference in a new issue