MCPcopy Create free account
hub / github.com/cloudbase/garm / TestTimeToLiveDuration

Function TestTimeToLiveDuration

config/config_test.go:528–545  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

526}
527
528func TestTimeToLiveDuration(t *testing.T) {
529 cfg := JWTAuth{
530 TimeToLive: "48h",
531 }
532
533 require.Equal(t, cfg.TimeToLive.Duration(), 48*time.Hour)
534
535 cfg.TimeToLive = "1h"
536 require.Equal(t, cfg.TimeToLive.Duration(), appdefaults.DefaultJWTTTL)
537
538 cfg.TimeToLive = "72h"
539 require.Equal(t, cfg.TimeToLive.Duration(), 72*time.Hour)
540
541 cfg.TimeToLive = "2d"
542 _, err := cfg.TimeToLive.ParseDuration()
543 require.NotNil(t, err)
544 require.EqualError(t, err, "time: unknown unit \"d\" in duration \"2d\"")
545}
546
547func TestNewConfig(t *testing.T) {
548 cfg, err := NewConfig("testdata/test-valid-config.toml")

Callers

nothing calls this directly

Calls 2

DurationMethod · 0.45
ParseDurationMethod · 0.45

Tested by

no test coverage detected