github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/sys/it/impl_n10n_test.go (about) 1 /* 2 * Copyright (c) 2021-present unTill Pro, Ltd. 3 */ 4 5 package sys_it 6 7 import ( 8 "testing" 9 10 "github.com/stretchr/testify/require" 11 12 "github.com/voedger/voedger/pkg/appdef" 13 "github.com/voedger/voedger/pkg/in10n" 14 "github.com/voedger/voedger/pkg/istructs" 15 it "github.com/voedger/voedger/pkg/vit" 16 ) 17 18 func TestBasicUsage_n10n(t *testing.T) { 19 if testing.Short() { 20 t.Skip() 21 } 22 require := require.New(t) 23 vit := it.NewVIT(t, &it.SharedConfig_App1) 24 defer vit.TearDown() 25 26 ws := vit.WS(istructs.AppQName_test1_app1, "test_ws") 27 testProjectionKey := in10n.ProjectionKey{ 28 App: istructs.AppQName_test1_app1, 29 Projection: appdef.NewQName("paa", "price"), 30 WS: ws.WSID, 31 } 32 33 offsetsChan, unsubscribe, err := vit.N10NSubscribe(testProjectionKey) 34 require.NoError(err) 35 36 done := make(chan interface{}) 37 go func() { 38 defer close(done) 39 for offset := range offsetsChan { 40 require.Equal(istructs.Offset(13), offset) 41 } 42 }() 43 44 // вызовем тестовый метод update для обновления проекции 45 vit.N10NUpdate(testProjectionKey, 13) 46 47 // отпишемся, чтобы закрылся канал offsetsChan 48 unsubscribe() 49 50 <-done // подождем чтения события и закрытия каналс offsestChan 51 }