Skip to content

Commit df17367

Browse files
committed
tz params test
1 parent 821f40d commit df17367

File tree

5 files changed

+363
-0
lines changed

5 files changed

+363
-0
lines changed

internal/params/builder_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,60 @@ func TestBuilder(t *testing.T) {
514514
},
515515
},
516516
},
517+
{
518+
name: xtest.CurrentFileLine(),
519+
builder: Builder{}.Param("$x").TzDatetime(time.Unix(123456789, 456).UTC()).Build(),
520+
params: map[string]*Ydb.TypedValue{
521+
"$x": {
522+
Type: &Ydb.Type{
523+
Type: &Ydb.Type_TypeId{
524+
TypeId: Ydb.Type_TZ_DATETIME,
525+
},
526+
},
527+
Value: &Ydb.Value{
528+
Value: &Ydb.Value_TextValue{
529+
TextValue: "1973-11-29T21:33:09Z",
530+
},
531+
},
532+
},
533+
},
534+
},
535+
{
536+
name: xtest.CurrentFileLine(),
537+
builder: Builder{}.Param("$x").TzDate(time.Unix(123456789, 456).UTC()).Build(),
538+
params: map[string]*Ydb.TypedValue{
539+
"$x": {
540+
Type: &Ydb.Type{
541+
Type: &Ydb.Type_TypeId{
542+
TypeId: Ydb.Type_TZ_DATE,
543+
},
544+
},
545+
Value: &Ydb.Value{
546+
Value: &Ydb.Value_TextValue{
547+
TextValue: "1973-11-29",
548+
},
549+
},
550+
},
551+
},
552+
},
553+
{
554+
name: xtest.CurrentFileLine(),
555+
builder: Builder{}.Param("$x").TzTimestamp(time.Unix(123456789, 456).UTC()).Build(),
556+
params: map[string]*Ydb.TypedValue{
557+
"$x": {
558+
Type: &Ydb.Type{
559+
Type: &Ydb.Type_TypeId{
560+
TypeId: Ydb.Type_TZ_TIMESTAMP,
561+
},
562+
},
563+
Value: &Ydb.Value{
564+
Value: &Ydb.Value_TextValue{
565+
TextValue: "1973-11-29T21:33:09.000000Z",
566+
},
567+
},
568+
},
569+
},
570+
},
517571
} {
518572
t.Run(tt.name, func(t *testing.T) {
519573
a := allocator.New()

internal/params/dict_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,51 @@ func TestDict(t *testing.T) {
362362
},
363363
},
364364
},
365+
{
366+
method: "TzDatetime",
367+
args: []any{time.Unix(123456789, 456).UTC()},
368+
369+
expected: expected{
370+
kind: &Ydb.Type{
371+
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_TZ_DATETIME},
372+
},
373+
value: &Ydb.Value{
374+
Value: &Ydb.Value_TextValue{
375+
TextValue: "1973-11-29T21:33:09Z",
376+
},
377+
},
378+
},
379+
},
380+
{
381+
method: "TzDate",
382+
args: []any{time.Unix(123456789, 456).UTC()},
383+
384+
expected: expected{
385+
kind: &Ydb.Type{
386+
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_TZ_DATE},
387+
},
388+
value: &Ydb.Value{
389+
Value: &Ydb.Value_TextValue{
390+
TextValue: "1973-11-29",
391+
},
392+
},
393+
},
394+
},
395+
{
396+
method: "TzTimestamp",
397+
args: []any{time.Unix(123456789, 456).UTC()},
398+
399+
expected: expected{
400+
kind: &Ydb.Type{
401+
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_TZ_TIMESTAMP},
402+
},
403+
value: &Ydb.Value{
404+
Value: &Ydb.Value_TextValue{
405+
TextValue: "1973-11-29T21:33:09.000000Z",
406+
},
407+
},
408+
},
409+
},
365410
}
366411

367412
for _, key := range tests {

internal/params/list_test.go

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,90 @@ func TestList(t *testing.T) {
673673
},
674674
},
675675
},
676+
{
677+
name: xtest.CurrentFileLine(),
678+
builder: Builder{}.Param("$x").BeginList().Add().TzDatetime(time.Unix(123456789, 456).UTC()).EndList(),
679+
params: map[string]*Ydb.TypedValue{
680+
"$x": {
681+
Type: &Ydb.Type{
682+
Type: &Ydb.Type_ListType{
683+
ListType: &Ydb.ListType{
684+
Item: &Ydb.Type{
685+
Type: &Ydb.Type_TypeId{
686+
TypeId: Ydb.Type_TZ_DATETIME,
687+
},
688+
},
689+
},
690+
},
691+
},
692+
Value: &Ydb.Value{
693+
Items: []*Ydb.Value{
694+
{
695+
Value: &Ydb.Value_TextValue{
696+
TextValue: "1973-11-29T21:33:09Z",
697+
},
698+
},
699+
},
700+
},
701+
},
702+
},
703+
},
704+
{
705+
name: xtest.CurrentFileLine(),
706+
builder: Builder{}.Param("$x").BeginList().Add().TzDate(time.Unix(123456789, 456).UTC()).EndList(),
707+
params: map[string]*Ydb.TypedValue{
708+
"$x": {
709+
Type: &Ydb.Type{
710+
Type: &Ydb.Type_ListType{
711+
ListType: &Ydb.ListType{
712+
Item: &Ydb.Type{
713+
Type: &Ydb.Type_TypeId{
714+
TypeId: Ydb.Type_TZ_DATE,
715+
},
716+
},
717+
},
718+
},
719+
},
720+
Value: &Ydb.Value{
721+
Items: []*Ydb.Value{
722+
{
723+
Value: &Ydb.Value_TextValue{
724+
TextValue: "1973-11-29",
725+
},
726+
},
727+
},
728+
},
729+
},
730+
},
731+
},
732+
{
733+
name: xtest.CurrentFileLine(),
734+
builder: Builder{}.Param("$x").BeginList().Add().TzTimestamp(time.Unix(123456789, 456).UTC()).EndList(),
735+
params: map[string]*Ydb.TypedValue{
736+
"$x": {
737+
Type: &Ydb.Type{
738+
Type: &Ydb.Type_ListType{
739+
ListType: &Ydb.ListType{
740+
Item: &Ydb.Type{
741+
Type: &Ydb.Type_TypeId{
742+
TypeId: Ydb.Type_TZ_TIMESTAMP,
743+
},
744+
},
745+
},
746+
},
747+
},
748+
Value: &Ydb.Value{
749+
Items: []*Ydb.Value{
750+
{
751+
Value: &Ydb.Value_TextValue{
752+
TextValue: "1973-11-29T21:33:09.000000Z",
753+
},
754+
},
755+
},
756+
},
757+
},
758+
},
759+
},
676760
} {
677761
t.Run(tt.name, func(t *testing.T) {
678762
a := allocator.New()

internal/params/optional_test.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,78 @@ func TestOptional(t *testing.T) {
553553
},
554554
},
555555
},
556+
{
557+
name: xtest.CurrentFileLine(),
558+
builder: Builder{}.Param("$x").BeginOptional().TzDatetime(time.Unix(123456789, 456).UTC()).EndOptional(),
559+
params: map[string]*Ydb.TypedValue{
560+
"$x": {
561+
Type: &Ydb.Type{
562+
Type: &Ydb.Type_OptionalType{
563+
OptionalType: &Ydb.OptionalType{
564+
Item: &Ydb.Type{
565+
Type: &Ydb.Type_TypeId{
566+
TypeId: Ydb.Type_TZ_DATETIME,
567+
},
568+
},
569+
},
570+
},
571+
},
572+
Value: &Ydb.Value{
573+
Value: &Ydb.Value_TextValue{
574+
TextValue: "1973-11-29T21:33:09Z",
575+
},
576+
},
577+
},
578+
},
579+
},
580+
{
581+
name: xtest.CurrentFileLine(),
582+
builder: Builder{}.Param("$x").BeginOptional().TzDate(time.Unix(123456789, 456).UTC()).EndOptional(),
583+
params: map[string]*Ydb.TypedValue{
584+
"$x": {
585+
Type: &Ydb.Type{
586+
Type: &Ydb.Type_OptionalType{
587+
OptionalType: &Ydb.OptionalType{
588+
Item: &Ydb.Type{
589+
Type: &Ydb.Type_TypeId{
590+
TypeId: Ydb.Type_TZ_DATE,
591+
},
592+
},
593+
},
594+
},
595+
},
596+
Value: &Ydb.Value{
597+
Value: &Ydb.Value_TextValue{
598+
TextValue: "1973-11-29",
599+
},
600+
},
601+
},
602+
},
603+
},
604+
{
605+
name: xtest.CurrentFileLine(),
606+
builder: Builder{}.Param("$x").BeginOptional().TzTimestamp(time.Unix(123456789, 456).UTC()).EndOptional(),
607+
params: map[string]*Ydb.TypedValue{
608+
"$x": {
609+
Type: &Ydb.Type{
610+
Type: &Ydb.Type_OptionalType{
611+
OptionalType: &Ydb.OptionalType{
612+
Item: &Ydb.Type{
613+
Type: &Ydb.Type_TypeId{
614+
TypeId: Ydb.Type_TZ_TIMESTAMP,
615+
},
616+
},
617+
},
618+
},
619+
},
620+
Value: &Ydb.Value{
621+
Value: &Ydb.Value_TextValue{
622+
TextValue: "1973-11-29T21:33:09.000000Z",
623+
},
624+
},
625+
},
626+
},
627+
},
556628
} {
557629
t.Run(tt.name, func(t *testing.T) {
558630
a := allocator.New()

internal/params/set_test.go

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,114 @@ func TestSet(t *testing.T) {
863863
},
864864
},
865865
},
866+
{
867+
name: xtest.CurrentFileLine(),
868+
builder: Builder{}.Param("$x").BeginSet().Add().TzDatetime(time.Unix(123456789, 456).UTC()).EndSet(),
869+
params: map[string]*Ydb.TypedValue{
870+
"$x": {
871+
Type: &Ydb.Type{
872+
Type: &Ydb.Type_DictType{
873+
DictType: &Ydb.DictType{
874+
Key: &Ydb.Type{
875+
Type: &Ydb.Type_TypeId{
876+
TypeId: Ydb.Type_TZ_DATETIME,
877+
},
878+
},
879+
Payload: &Ydb.Type{
880+
Type: &Ydb.Type_VoidType{},
881+
},
882+
},
883+
},
884+
},
885+
Value: &Ydb.Value{
886+
Pairs: []*Ydb.ValuePair{
887+
{
888+
Key: &Ydb.Value{
889+
Value: &Ydb.Value_TextValue{
890+
TextValue: "1973-11-29T21:33:09Z",
891+
},
892+
},
893+
Payload: &Ydb.Value{
894+
Value: &Ydb.Value_NullFlagValue{},
895+
},
896+
},
897+
},
898+
},
899+
},
900+
},
901+
},
902+
{
903+
name: xtest.CurrentFileLine(),
904+
builder: Builder{}.Param("$x").BeginSet().Add().TzDate(time.Unix(123456789, 456).UTC()).EndSet(),
905+
params: map[string]*Ydb.TypedValue{
906+
"$x": {
907+
Type: &Ydb.Type{
908+
Type: &Ydb.Type_DictType{
909+
DictType: &Ydb.DictType{
910+
Key: &Ydb.Type{
911+
Type: &Ydb.Type_TypeId{
912+
TypeId: Ydb.Type_TZ_DATE,
913+
},
914+
},
915+
Payload: &Ydb.Type{
916+
Type: &Ydb.Type_VoidType{},
917+
},
918+
},
919+
},
920+
},
921+
Value: &Ydb.Value{
922+
Pairs: []*Ydb.ValuePair{
923+
{
924+
Key: &Ydb.Value{
925+
Value: &Ydb.Value_TextValue{
926+
TextValue: "1973-11-29",
927+
},
928+
},
929+
Payload: &Ydb.Value{
930+
Value: &Ydb.Value_NullFlagValue{},
931+
},
932+
},
933+
},
934+
},
935+
},
936+
},
937+
},
938+
{
939+
name: xtest.CurrentFileLine(),
940+
builder: Builder{}.Param("$x").BeginSet().Add().TzTimestamp(time.Unix(123456789, 456).UTC()).EndSet(),
941+
params: map[string]*Ydb.TypedValue{
942+
"$x": {
943+
Type: &Ydb.Type{
944+
Type: &Ydb.Type_DictType{
945+
DictType: &Ydb.DictType{
946+
Key: &Ydb.Type{
947+
Type: &Ydb.Type_TypeId{
948+
TypeId: Ydb.Type_TZ_TIMESTAMP,
949+
},
950+
},
951+
Payload: &Ydb.Type{
952+
Type: &Ydb.Type_VoidType{},
953+
},
954+
},
955+
},
956+
},
957+
Value: &Ydb.Value{
958+
Pairs: []*Ydb.ValuePair{
959+
{
960+
Key: &Ydb.Value{
961+
Value: &Ydb.Value_TextValue{
962+
TextValue: "1973-11-29T21:33:09.000000Z",
963+
},
964+
},
965+
Payload: &Ydb.Value{
966+
Value: &Ydb.Value_NullFlagValue{},
967+
},
968+
},
969+
},
970+
},
971+
},
972+
},
973+
},
866974
} {
867975
t.Run(tt.name, func(t *testing.T) {
868976
a := allocator.New()

0 commit comments

Comments
 (0)