Skip to content

Commit

Permalink
Add test for calling stack.FunctionID from anonymous go call
Browse files Browse the repository at this point in the history
  • Loading branch information
anatoly32322 committed Mar 30, 2024
1 parent 12a90c9 commit 1a46618
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/stack/function_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package stack

import (
"testing"
"time"

"github.com/stretchr/testify/require"
)
Expand All @@ -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

Check failure on line 32 in internal/stack/function_id_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

return with no blank line before (nlreturn)
}

func TestFunctionIDForGenericType(t *testing.T) {
t.Run("StaticFunc", func(t *testing.T) {
require.Equal(t,
Expand All @@ -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(),
)
})
}

0 comments on commit 1a46618

Please sign in to comment.