photoprism/pkg/report/timestamp_test.go
Michael Mayer 713593da4e Auth: Add CLI command to create access tokens for apps #782 #808 #3943
You can now run "photoprism auth add" to create new client access tokens
that allow external applications to use the built-in REST API.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-05 16:31:07 +01:00

33 lines
645 B
Go

package report
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestDateTime(t *testing.T) {
t.Run("Nil", func(t *testing.T) {
assert.Equal(t, "", DateTime(nil))
})
t.Run("Zero", func(t *testing.T) {
assert.Equal(t, "", DateTime(&time.Time{}))
})
t.Run("1665389030", func(t *testing.T) {
now := time.Unix(1665389030, 0)
assert.Equal(t, "2022-10-10 08:03:50", DateTime(&now))
})
}
func TestUnixTime(t *testing.T) {
t.Run("Zero", func(t *testing.T) {
assert.Equal(t, "", UnixTime(0))
})
t.Run("1665389030", func(t *testing.T) {
assert.Equal(t, "2022-10-10 08:03:50", UnixTime(1665389030))
})
}