Skip to content

Commit

Permalink
Merge pull request #1443 from mesg-foundation/feature/e2e-event-test
Browse files Browse the repository at this point in the history
e2e event test
  • Loading branch information
antho1404 authored Oct 30, 2019
2 parents 452044a + 1788933 commit a405ad5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions e2e/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ func TestAPI(t *testing.T) {
t.Run("service", testService)
t.Run("ownership", testOwnership)
t.Run("instance", testInstance)
t.Run("event", testEvent)
t.Run("instance/delete", testDeleteInstance)
}
42 changes: 42 additions & 0 deletions e2e/event_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"context"
"testing"

"github.com/mesg-foundation/engine/protobuf/acknowledgement"
pb "github.com/mesg-foundation/engine/protobuf/api"
"github.com/mesg-foundation/engine/protobuf/types"
"github.com/stretchr/testify/require"
)

func testEvent(t *testing.T) {
stream, err := client.EventClient.Stream(context.Background(), &pb.StreamEventRequest{
Filter: &pb.StreamEventRequest_Filter{},
})
require.NoError(t, err)
acknowledgement.WaitForStreamToBeReady(stream)

resp, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{
InstanceHash: testInstanceHash,
Key: "ping_ok",
Data: &types.Struct{
Fields: map[string]*types.Value{
"msg": {
Kind: &types.Value_StringValue{
StringValue: "foo",
},
},
},
},
})
require.NoError(t, err)

event, err := stream.Recv()
require.NoError(t, err)

require.Equal(t, resp.Hash, event.Hash)
require.Equal(t, testInstanceHash, event.InstanceHash)
require.Equal(t, "ping_ok", event.Key)
require.Equal(t, "foo", event.Data.Fields["msg"].GetStringValue())
}

0 comments on commit a405ad5

Please sign in to comment.