github.com/TBD54566975/ftl@v0.219.0/internal/modulecontext/module_context_test.go (about)

     1  package modulecontext
     2  
     3  import (
     4  	"context" //nolint:depguard
     5  	"testing"
     6  
     7  	"github.com/alecthomas/assert/v2"
     8  
     9  	"github.com/TBD54566975/ftl/internal/log"
    10  )
    11  
    12  func TestGettingAndSettingFromContext(t *testing.T) {
    13  	ctx := log.ContextWithNewDefaultLogger(context.Background())
    14  	moduleCtx := NewBuilder("test").Build()
    15  	ctx = moduleCtx.ApplyToContext(ctx)
    16  	assert.Equal(t, moduleCtx, FromContext(ctx), "module context should be the same when read from context")
    17  }