Skip to content

Commit fc73260

Browse files
use a channel to delay test from moving on until whispers have completed
1 parent 5ab2d7c commit fc73260

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

ldk/go/examples/filesystem-directory/loop/loop_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
)
1414

1515
func TestController(t *testing.T) {
16+
markdownDoneChan := make(chan bool)
17+
1618
type template struct {
1719
Name string
1820
Size int
@@ -37,6 +39,7 @@ func TestController(t *testing.T) {
3739
if got := w.Markdown; !cmp.Equal(got, exp) {
3840
t.Errorf("unexpected markdown:\n%s\n", cmp.Diff(got, exp))
3941
}
42+
markdownDoneChan <- true
4043
return nil
4144
},
4245
},
@@ -49,6 +52,7 @@ func TestController(t *testing.T) {
4952
if err := c.LoopStart(sidekick); err != nil {
5053
t.Fatal(err)
5154
}
55+
<-markdownDoneChan
5256
if err := c.LoopStop(); err != nil {
5357
t.Fatal(err)
5458
}

ldk/go/examples/filesystem-listen-directory/loop/loop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (c *Loop) emitExampleWhisper(fe ldk.FileEvent) error {
128128
}
129129
}()
130130

131-
// c.logger.Info("Sent message", "markdown", markdownBytes.String())
131+
c.logger.Info("Sent message", "markdown", markdownBytes.String())
132132

133133
return nil
134134
}

ldk/go/examples/filesystem-listen-directory/loop/loop_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
)
1414

1515
func TestController(t *testing.T) {
16+
markdownDoneChan := make(chan bool)
17+
1618
sidekick := &ldktest.Sidekick{
1719
FilesystemService: &ldktest.FilesystemService{
1820
ListenDirf: func(ctx context.Context, dir string, cb ldk.ListenDirHandler) error {
@@ -27,6 +29,7 @@ func TestController(t *testing.T) {
2729
if got := w.Markdown; !cmp.Equal(got, exp) {
2830
t.Errorf("unexpected markdown:\n%s\n", cmp.Diff(got, exp))
2931
}
32+
markdownDoneChan <- true
3033
return nil
3134
},
3235
},
@@ -39,6 +42,7 @@ func TestController(t *testing.T) {
3942
if err := c.LoopStart(sidekick); err != nil {
4043
t.Fatal(err)
4144
}
45+
<-markdownDoneChan
4246
if err := c.LoopStop(); err != nil {
4347
t.Fatal(err)
4448
}

0 commit comments

Comments
 (0)