Skip to content

Commit

Permalink
fix broken pubsub refs and names
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanj-square committed Aug 13, 2024
1 parent 3dfd8ac commit 80d4330
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions go-runtime/ftl/ftltest/testdata/go/pubsub/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
)

//ftl:export
var Topic1 = ftl.Topic[Event]("topic1")
var Topic1 = ftl.Topic[Event]("topic_1")

//ftl:export
var Topic2 = ftl.Topic[Event]("topic2")
var Topic2 = ftl.Topic[Event]("topic_2")

var subscription1_1 = ftl.Subscription(Topic1, "subscription1_1")
var subscription1_2 = ftl.Subscription(Topic1, "subscription1_2")
var subscription2_1 = ftl.Subscription(Topic2, "subscription2_1")
var subscription2_2 = ftl.Subscription(Topic2, "subscription2_3")
var subscription1_1 = ftl.Subscription(Topic1, "subscription_1_1")
var subscription1_2 = ftl.Subscription(Topic1, "subscription_1_2")
var subscription2_1 = ftl.Subscription(Topic2, "subscription_2_1")
var subscription2_2 = ftl.Subscription(Topic2, "subscription_2_3")

//ftl:data
type Event struct {
Expand All @@ -40,7 +40,7 @@ func ConsumeEvent(_ context.Context, _ Event) error {
return nil
}

//ftl:subscribe subscription
//ftl:subscribe subscription_1_1
func ErrorsAfterASecond(ctx context.Context, event Event) error {
time.Sleep(1 * time.Second)
return fmt.Errorf("SubscriberThatFails always fails")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import (
"github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK.
)

var _ = ftl.Subscription(pubsub.Topic, "subscription")
var _ = ftl.Subscription(pubsub.Topic1, "subscription1_1")
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (

func TestPublishToExternalModule(t *testing.T) {
ctx := ftltest.Context()
assert.NoError(t, pubsub.Topic.Publish(ctx, pubsub.Event{Value: "external"}))
assert.Equal(t, 1, len(ftltest.EventsForTopic(ctx, pubsub.Topic)))
assert.NoError(t, pubsub.Topic1.Publish(ctx, pubsub.Event{Value: "external"}))
assert.Equal(t, 1, len(ftltest.EventsForTopic(ctx, pubsub.Topic1)))

// Make sure we correctly made the right ref for the external module.
assert.Equal(t, "pubsub", pubsub.Topic.Ref.Module)
assert.Equal(t, "pubsub", pubsub.Topic1.Ref.Module)
}

0 comments on commit 80d4330

Please sign in to comment.