use a package-level variable to set the key update frequency

This commit is contained in:
Marten Seemann
2020-09-08 11:11:16 +07:00
parent 72d81f6951
commit a063500d73
4 changed files with 8 additions and 54 deletions

View File

@@ -4,7 +4,6 @@ import (
"crypto/rand"
"crypto/tls"
"fmt"
"os"
"time"
"github.com/golang/mock/gomock"
@@ -452,29 +451,6 @@ var _ = Describe("Updatable AEAD", func() {
Expect(err).ToNot(HaveOccurred())
})
})
Context("reading the key update env", func() {
AfterEach(func() {
os.Setenv(keyUpdateEnv, "")
setKeyUpdateInterval()
})
It("uses the default value if the env is not set", func() {
setKeyUpdateInterval()
Expect(keyUpdateInterval).To(BeEquivalentTo(protocol.KeyUpdateInterval))
})
It("uses the env", func() {
os.Setenv(keyUpdateEnv, "1337")
setKeyUpdateInterval()
Expect(keyUpdateInterval).To(BeEquivalentTo(1337))
})
It("panics when it can't parse the env", func() {
os.Setenv(keyUpdateEnv, "foobar")
Expect(setKeyUpdateInterval).To(Panic())
})
})
})
})
})