mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-04 23:28:32 +00:00
37 lines
822 B
Go
37 lines
822 B
Go
package sprig
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestHtmlDate(t *testing.T) {
|
|
t.Skip()
|
|
tpl := `{{ htmlDate 0}}`
|
|
if err := runt(tpl, "1970-01-01"); err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|
|
|
|
func TestAgo(t *testing.T) {
|
|
tpl := "{{ ago .Time }}"
|
|
if err := runtv(tpl, "2m5s", map[string]interface{}{"Time": time.Now().Add(-125 * time.Second)}); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if err := runtv(tpl, "2h34m17s", map[string]interface{}{"Time": time.Now().Add(-(2*3600 + 34*60 + 17) * time.Second)}); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if err := runtv(tpl, "-5s", map[string]interface{}{"Time": time.Now().Add(5 * time.Second)}); err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|
|
|
|
func TestToDate(t *testing.T) {
|
|
tpl := `{{toDate "2006-01-02" "2017-12-31" | date "02/01/2006"}}`
|
|
if err := runt(tpl, "31/12/2017"); err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|