Annoucement expiration time parsing
This commit is contained in:
@@ -3,8 +3,8 @@ package constants
|
||||
const (
|
||||
// Annoucement is a message annoucement
|
||||
Annoucement = "Support for Mullvad"
|
||||
// AnnoucementExpiration is the expiration time of the annoucement in unix timestamp
|
||||
AnnoucementExpiration = 1584981407
|
||||
// AnnoucementExpiration is the expiration date of the annoucement in format yyyy-mm-dd
|
||||
AnnoucementExpiration = "2020-03-15"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
17
internal/constants/splash_test.go
Normal file
17
internal/constants/splash_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package constants
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_AnnoucementExpiration(t *testing.T) {
|
||||
t.Parallel()
|
||||
if len(AnnoucementExpiration) == 0 {
|
||||
return
|
||||
}
|
||||
_, err := time.Parse("2006-01-02", AnnoucementExpiration)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@@ -1,21 +1,20 @@
|
||||
package params
|
||||
|
||||
import (
|
||||
"github.com/qdm12/golibs/params"
|
||||
libparams "github.com/qdm12/golibs/params"
|
||||
)
|
||||
|
||||
func (p *paramsReader) GetVersion() string {
|
||||
version, _ := p.envParams.GetEnv("VERSION", params.Default("?"), libparams.CaseSensitiveValue())
|
||||
version, _ := p.envParams.GetEnv("VERSION", libparams.Default("?"), libparams.CaseSensitiveValue())
|
||||
return version
|
||||
}
|
||||
|
||||
func (p *paramsReader) GetBuildDate() string {
|
||||
buildDate, _ := p.envParams.GetEnv("BUILD_DATE", params.Default("?"), libparams.CaseSensitiveValue())
|
||||
buildDate, _ := p.envParams.GetEnv("BUILD_DATE", libparams.Default("?"), libparams.CaseSensitiveValue())
|
||||
return buildDate
|
||||
}
|
||||
|
||||
func (p *paramsReader) GetVcsRef() string {
|
||||
buildDate, _ := p.envParams.GetEnv("VCS_REF", params.Default("?"), libparams.CaseSensitiveValue())
|
||||
buildDate, _ := p.envParams.GetEnv("VCS_REF", libparams.Default("?"), libparams.CaseSensitiveValue())
|
||||
return buildDate
|
||||
}
|
||||
|
||||
@@ -39,11 +39,14 @@ func title() []string {
|
||||
}
|
||||
|
||||
func annoucement() []string {
|
||||
timestamp := time.Now().UnixNano() / 1000000000
|
||||
if timestamp < constants.AnnoucementExpiration {
|
||||
return []string{emoji.Sprint(":mega: ") + constants.Annoucement}
|
||||
if len(constants.Annoucement) == 0 {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
expirationDate, _ := time.Parse("2006-01-02", constants.AnnoucementExpiration) // error covered by a unit test
|
||||
if time.Now().After(expirationDate) {
|
||||
return nil
|
||||
}
|
||||
return []string{emoji.Sprint(":mega: ") + constants.Annoucement}
|
||||
}
|
||||
|
||||
func links() []string {
|
||||
|
||||
Reference in New Issue
Block a user