Esempio n. 1
0
func TestCreateEventClientFlow(t *testing.T) {
	var (
		applicationID = os.Getenv("GP_APPLICATION_ID")
		credentialID  = os.Getenv("GP_CREDENTIAL_ID")
	)
	gpDispatcherClient := dispatcher.NewClientWithParam(applicationID, credentialID)
	newEventRes, newEventErr := events.CreateNewEvent(gpDispatcherClient, events.CreateNewEventRequest{
		Name: getRandomName(),
	})
	if newEventErr != nil {
		t.Fatal(newEventErr)
	}

	clientID := mustGetClientID(t, gpDispatcherClient)

	newEventClientRes, newEventClientErr := eventclients.CreateNewEventClient(gpDispatcherClient, eventclients.CreateNewEventClientRequest{
		ClientID: clientID,
		EventID:  newEventRes.ID.String(),
	})
	if newEventClientErr != nil {
		t.Fatal(newEventClientErr)
	}

	t.Log(newEventClientRes)
}
Esempio n. 2
0
func TestGetEvents(t *testing.T) {
	var (
		applicationID = os.Getenv("GP_APPLICATION_ID")
		credentialID  = os.Getenv("GP_CREDENTIAL_ID")
	)
	gpDispatcherClient := dispatcher.NewClientWithParam(applicationID, credentialID)

	var startID string
	for index := 0; index <= 1; index++ {
		req := events.GetEventsRequest{
			Limit:            "5",
			ExclusiveStartID: startID,
		}
		res, err := events.GetEvents(gpDispatcherClient, req)
		if err != nil {
			t.Fatal(err)
		}
		size := len(res)
		if size == 0 {
			break
		}
		t.Log(res)
		startID = res[size-1].ID.String()
	}
}