-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix markdown linting * add dependency injection example * update readme with di * fix markdown code annotation * fix readme * one more readme fix
- Loading branch information
1 parent
ee2994c
commit bb5538a
Showing
5 changed files
with
143 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package di | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
) | ||
|
||
// PrintCheckList to show D.I. | ||
// | ||
// dependency Injection makes testing easier | ||
// by creating functions that get all their | ||
// dependencies are arguments | ||
func PrintCheckList(writer io.Writer, list []string) { | ||
for _, item := range list { | ||
fmt.Fprintln(writer, item) | ||
} | ||
} |
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,30 @@ | ||
package di | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
. "github.com/smartystreets/goconvey/convey" | ||
) | ||
|
||
func TestPrintCheckList(t *testing.T) { | ||
Convey("Given a checklist", t, func() { | ||
buffer := &bytes.Buffer{} | ||
checklist := []string{ | ||
"[✓] Get milk", | ||
"[✓] Learn Go", | ||
"[✗] Book holidays", | ||
} | ||
|
||
PrintCheckList(buffer, checklist) | ||
|
||
got := buffer.String() | ||
want := `[✓] Get milk | ||
[✓] Learn Go | ||
[✗] Book holidays | ||
` | ||
Convey("expect list items to be printed", func() { | ||
So(got, ShouldEqual, want) | ||
}) | ||
}) | ||
} |
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,7 @@ | ||
module github.com/iampeterbanjo/golang-examples | ||
|
||
require ( | ||
github.com/jtolds/gls v4.2.1+incompatible // indirect | ||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect | ||
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a | ||
) |
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,6 @@ | ||
github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= | ||
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= | ||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= | ||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= | ||
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a h1:JSvGDIbmil4Ui/dDdFBExb7/cmkNjyX5F97oglmvCDo= | ||
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= |
Oops, something went wrong.