mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-05-01 07:00:13 -05:00
77e5d2b77c
* feat(go-sdk): spawnWorkflow method and get up to speed with other sdks * fix: manual trigger example * fix: linting errors * fix: double serialization from go sdk * fix: spawn workflow logic and procedural example * test(e2e): add procedural test * fix: panic in e2e test * fix: e2e test preparation * fix: api server url in test.yml * fix: load test server url * chore: make num children configurable * address pr review
54 lines
924 B
Go
54 lines
924 B
Go
//go:build e2e
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/hatchet-dev/hatchet/internal/testutils"
|
|
)
|
|
|
|
func TestProcedural(t *testing.T) {
|
|
testutils.Prepare(t)
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
|
defer cancel()
|
|
|
|
events := make(chan string, 5*NUM_CHILDREN)
|
|
|
|
cleanup, err := run(events)
|
|
if err != nil {
|
|
t.Fatalf("/run() error = %v", err)
|
|
}
|
|
|
|
var items []string
|
|
|
|
outer:
|
|
for {
|
|
select {
|
|
case item := <-events:
|
|
items = append(items, item)
|
|
case <-ctx.Done():
|
|
break outer
|
|
}
|
|
}
|
|
|
|
expected := []string{}
|
|
|
|
for i := 0; i < NUM_CHILDREN; i++ {
|
|
expected = append(expected, fmt.Sprintf("child-%d-started", i))
|
|
expected = append(expected, fmt.Sprintf("child-%d-completed", i))
|
|
}
|
|
|
|
assert.ElementsMatch(t, expected, items)
|
|
|
|
if err := cleanup(); err != nil {
|
|
t.Fatalf("cleanup() error = %v", err)
|
|
}
|
|
}
|