package js import ( "context" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "src.dualinventive.com/go/devsim/simulator/testdata" "src.dualinventive.com/go/dinet/rpc" ) // Test publish without result and with result map and array func TestPublish(t *testing.T) { m, tt := model(t) s, err := newSimulator(m, &testdata.Info{IPath: "testdata/publish"}) require.Nil(t, err) s.Start() defer s.Stop() for i := 0; i < 4; i++ { pub, _ := tt.Dequeue(context.Background()) require.Equal(t, rpc.MsgTypePublish, pub.Type) assert.NotEmpty(t, pub.ClassMethod) if pub.ClassMethod != rpc.ClassMethodDevicePing { assert.NotNil(t, pub.Result) } else { assert.Nil(t, pub.Result) } } }