File: timestamp_test.go

package info (click to toggle)
golang-github-jackc-pgtype 1.10.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,656 kB
  • sloc: sh: 32; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 787 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package zeronull_test

import (
	"testing"
	"time"

	"github.com/jackc/pgtype/testutil"
	"github.com/jackc/pgtype/zeronull"
)

func TestTimestampTranscode(t *testing.T) {
	testutil.TestSuccessfulTranscodeEqFunc(t, "timestamp", []interface{}{
		(zeronull.Timestamp)(time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)),
		(zeronull.Timestamp)(time.Time{}),
	}, func(a, b interface{}) bool {
		at := a.(zeronull.Timestamp)
		bt := b.(zeronull.Timestamp)

		return time.Time(at).Equal(time.Time(bt))
	})
}

func TestTimestampConvertsGoZeroToNull(t *testing.T) {
	testutil.TestGoZeroToNullConversion(t, "timestamp", (zeronull.Timestamp)(time.Time{}))
}

func TestTimestampConvertsNullToGoZero(t *testing.T) {
	testutil.TestNullToGoZeroConversion(t, "timestamp", (zeronull.Timestamp)(time.Time{}))
}