Skip to content

Commit 5a3754f

Browse files
committed
add TestDescribeTableRegression
1 parent 2522235 commit 5a3754f

File tree

1 file changed

+130
-0
lines changed

1 file changed

+130
-0
lines changed

internal/table/session_test.go

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,3 +491,133 @@ func TestCreateTableRegression(t *testing.T) {
491491

492492
require.NoError(t, err, "")
493493
}
494+
495+
func TestDescribeTableRegression(t *testing.T) {
496+
client := New(
497+
testutil.NewRouter(
498+
testutil.WithInvokeHandlers(
499+
testutil.InvokeHandlers{
500+
testutil.TableCreateSession: func(request interface{}) (proto.Message, error) {
501+
return &Ydb_Table.CreateSessionResult{
502+
SessionId: "",
503+
}, nil
504+
},
505+
testutil.TableDescribeTable: func(act interface{}) (proto.Message, error) {
506+
return &Ydb_Table.DescribeTableResult{
507+
Self: &Ydb_Scheme.Entry{
508+
Name: "episodes",
509+
},
510+
Columns: []*Ydb_Table.ColumnMeta{
511+
{
512+
Name: "series_id",
513+
Type: &Ydb.Type{Type: &Ydb.Type_OptionalType{
514+
OptionalType: &Ydb.OptionalType{Item: &Ydb.Type{Type: &Ydb.Type_TypeId{
515+
TypeId: Ydb.Type_UINT64,
516+
}}},
517+
}},
518+
},
519+
{
520+
Name: "season_id",
521+
Type: &Ydb.Type{Type: &Ydb.Type_OptionalType{
522+
OptionalType: &Ydb.OptionalType{Item: &Ydb.Type{Type: &Ydb.Type_TypeId{
523+
TypeId: Ydb.Type_UINT64,
524+
}}},
525+
}},
526+
},
527+
{
528+
Name: "episode_id",
529+
Type: &Ydb.Type{Type: &Ydb.Type_OptionalType{
530+
OptionalType: &Ydb.OptionalType{Item: &Ydb.Type{Type: &Ydb.Type_TypeId{
531+
TypeId: Ydb.Type_UINT64,
532+
}}},
533+
}},
534+
},
535+
{
536+
Name: "title",
537+
Type: &Ydb.Type{Type: &Ydb.Type_OptionalType{
538+
OptionalType: &Ydb.OptionalType{Item: &Ydb.Type{Type: &Ydb.Type_TypeId{
539+
TypeId: Ydb.Type_UTF8,
540+
}}},
541+
}},
542+
},
543+
{
544+
Name: "air_date",
545+
Type: &Ydb.Type{Type: &Ydb.Type_OptionalType{
546+
OptionalType: &Ydb.OptionalType{Item: &Ydb.Type{Type: &Ydb.Type_TypeId{
547+
TypeId: Ydb.Type_UINT64,
548+
}}},
549+
}},
550+
},
551+
},
552+
PrimaryKey: []string{
553+
"series_id",
554+
"season_id",
555+
"episode_id",
556+
},
557+
Attributes: map[string]string{
558+
"attr": "attr_value",
559+
},
560+
}, nil
561+
},
562+
},
563+
),
564+
),
565+
config.New(),
566+
)
567+
568+
ctx, cancel := context.WithTimeout(
569+
context.Background(),
570+
time.Second,
571+
)
572+
defer cancel()
573+
574+
var act options.Description
575+
576+
err := client.Do(ctx, func(ctx context.Context, s table.Session) (err error) {
577+
act, err = s.DescribeTable(ctx, "episodes")
578+
return err
579+
})
580+
581+
require.NoError(t, err, "")
582+
583+
exp := options.Description{
584+
Name: "episodes",
585+
Columns: []options.Column{
586+
{
587+
Name: "series_id",
588+
Type: types.Optional(types.TypeUint64),
589+
},
590+
{
591+
Name: "season_id",
592+
Type: types.Optional(types.TypeUint64),
593+
},
594+
{
595+
Name: "episode_id",
596+
Type: types.Optional(types.TypeUint64),
597+
},
598+
{
599+
Name: "title",
600+
Type: types.Optional(types.TypeUTF8),
601+
},
602+
{
603+
Name: "air_date",
604+
Type: types.Optional(types.TypeUint64),
605+
},
606+
},
607+
KeyRanges: []options.KeyRange{
608+
{},
609+
},
610+
PrimaryKey: []string{
611+
"series_id",
612+
"season_id",
613+
"episode_id",
614+
},
615+
Attributes: map[string]string{
616+
"attr": "attr_value",
617+
},
618+
}
619+
620+
if fmt.Sprintf("%+v", act) != fmt.Sprintf("%+v", exp) {
621+
t.Fatalf("description's not equal: \n\nact: %+v\n\nexp: %+v\n\n", act, exp)
622+
}
623+
}

0 commit comments

Comments
 (0)