Skip to content

Commit

Permalink
- Added: Example test for simple promise
Browse files Browse the repository at this point in the history
  • Loading branch information
donutloop committed Sep 30, 2017
1 parent a7c80bb commit ae6ce38
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion loop/doc_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package loop_test

import (
"fmt"
"github.com/donutloop/toolkit/loop"
"time"
"fmt"
)

func ExampleLoop() {
Expand Down
23 changes: 23 additions & 0 deletions promise/doc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package promise_test

import (
"context"
"fmt"
"github.com/donutloop/toolkit/promise"
)

func ExamplePromise() {

done, errc := promise.Do(context.Background(), func(ctx context.Context) error {
fmt.Println("do things")
return nil
})

select {
case <-done:
case err := <-errc:
fmt.Println(fmt.Sprintf("error: %v", err))
}

// Output: do things
}

0 comments on commit ae6ce38

Please sign in to comment.