github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/stream/typed_test.go (about)

     1  package stream
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/asynkron/protoactor-go/actor"
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestReceiveFromTypedStream(t *testing.T) {
    11  	system := actor.NewActorSystem()
    12  	s := NewTypedStream[string](system)
    13  	go func() {
    14  		rootContext := system.Root
    15  		rootContext.Send(s.PID(), "hello")
    16  		rootContext.Send(s.PID(), "you")
    17  	}()
    18  	res := <-s.C()
    19  	res2 := <-s.C()
    20  	assert.Equal(t, "hello", res)
    21  	assert.Equal(t, "you", res2)
    22  }