-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from lovoo/improve-emitter-mock
bugfix tester, improve emitter and mock
- Loading branch information
Showing
3 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package tester | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"testing" | ||
|
||
"github.com/lovoo/goka" | ||
"github.com/lovoo/goka/codec" | ||
) | ||
|
||
func Test_Blubb(t *testing.T) { | ||
|
||
kafkaMock := New(t).SetCodec(new(codec.String)) | ||
|
||
proc, err := goka.NewProcessor([]string{}, goka.DefineGroup("group", | ||
goka.Input("group-testloop", new(codec.String), func(ctx goka.Context, msg interface{}) { | ||
log.Printf("%v", msg) | ||
}), | ||
goka.Input("topic", new(codec.String), func(ctx goka.Context, msg interface{}) { | ||
ctx.Emit("group-testloop", "key", msg) | ||
}), | ||
goka.Output("group-testloop", new(codec.String)), | ||
goka.Persist(new(codec.String)), | ||
), | ||
goka.WithTester(kafkaMock), | ||
) | ||
if err != nil { | ||
log.Fatalf("%v", err) | ||
} | ||
|
||
ctx, cancel := context.WithCancel(context.Background()) | ||
done := make(chan bool) | ||
go func() { | ||
proc.Run(ctx) | ||
close(done) | ||
}() | ||
kafkaMock.ConsumeString("topic", "sender", "message") | ||
cancel() | ||
<-done | ||
} |