From 1a466186b181f6cb7cc4eef0de1fabee47c9a54b Mon Sep 17 00:00:00 2001 From: anatoly32322 Date: Sat, 30 Mar 2024 15:41:16 +0300 Subject: [PATCH] Add test for calling stack.FunctionID from anonymous go call --- internal/stack/function_id_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/stack/function_id_test.go b/internal/stack/function_id_test.go index f1161fe3d..9da417dbc 100644 --- a/internal/stack/function_id_test.go +++ b/internal/stack/function_id_test.go @@ -2,6 +2,7 @@ package stack import ( "testing" + "time" "github.com/stretchr/testify/require" ) @@ -22,6 +23,15 @@ func (e *starType) starredCall() string { return FunctionID("").FunctionID() } +func anonymousFunctionCall() string { + var result string + go func() { + result = FunctionID("").FunctionID() + }() + time.Sleep(time.Second) + return result +} + func TestFunctionIDForGenericType(t *testing.T) { t.Run("StaticFunc", func(t *testing.T) { require.Equal(t, @@ -42,4 +52,10 @@ func TestFunctionIDForGenericType(t *testing.T) { x.starredCall(), ) }) + t.Run("AnonymousFunctionCall", func(t *testing.T) { + require.Equal(t, + "github.com/ydb-platform/ydb-go-sdk/v3/internal/stack.anonymousFunctionCall", + anonymousFunctionCall(), + ) + }) }