Skip to content

Commit

Permalink
fix space indentation in Go code block (quii#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
apahie authored Sep 29, 2022
1 parent af9eef6 commit c9a369d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
32 changes: 16 additions & 16 deletions io.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ func TestFileSystemStore(t *testing.T) {

t.Run("league from a reader", func(t *testing.T) {
database := strings.NewReader(`[
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)

store := FileSystemPlayerStore{database}

Expand Down Expand Up @@ -335,8 +335,8 @@ Next we'll implement `GetPlayerScore`.
//file_system_store_test.go
t.Run("get player score", func(t *testing.T) {
database := strings.NewReader(`[
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)

store := FileSystemPlayerStore{database}

Expand Down Expand Up @@ -404,8 +404,8 @@ You will have seen dozens of test helper refactorings so I'll leave this to you
//file_system_store_test.go
t.Run("get player score", func(t *testing.T) {
database := strings.NewReader(`[
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)

store := FileSystemPlayerStore{database}

Expand Down Expand Up @@ -493,8 +493,8 @@ func TestFileSystemStore(t *testing.T) {

t.Run("league from a reader", func(t *testing.T) {
database, cleanDatabase := createTempFile(t, `[
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
defer cleanDatabase()

store := FileSystemPlayerStore{database}
Expand All @@ -515,8 +515,8 @@ func TestFileSystemStore(t *testing.T) {

t.Run("get player score", func(t *testing.T) {
database, cleanDatabase := createTempFile(t, `[
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
defer cleanDatabase()

store := FileSystemPlayerStore{database}
Expand All @@ -536,8 +536,8 @@ Let's get the first iteration of recording a win for an existing player
//file_system_store_test.go
t.Run("store wins for existing players", func(t *testing.T) {
database, cleanDatabase := createTempFile(t, `[
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
defer cleanDatabase()

store := FileSystemPlayerStore{database}
Expand Down Expand Up @@ -661,8 +661,8 @@ We now need to handle the scenario of recording wins of new players.
//file_system_store_test.go
t.Run("store wins for new players", func(t *testing.T) {
database, cleanDatabase := createTempFile(t, `[
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
defer cleanDatabase()

store := FileSystemPlayerStore{database}
Expand Down Expand Up @@ -1210,8 +1210,8 @@ We can update the assertion on our first test in `TestFileSystemStore`:
//file_system_store_test.go
t.Run("league sorted", func(t *testing.T) {
database, cleanDatabase := createTempFile(t, `[
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
{"Name": "Cleo", "Wins": 10},
{"Name": "Chris", "Wins": 33}]`)
defer cleanDatabase()

store, err := NewFileSystemPlayerStore(database)
Expand Down
30 changes: 15 additions & 15 deletions reading-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,12 @@ Description: Description 2
Tags: rust, borrow-checker`
)

// rest of test code cut for brevity
assertPost(t, posts[0], blogposts.Post{
Title: "Post 1",
Description: "Description 1",
Tags: []string{"tdd", "go"},
})
// rest of test code cut for brevity
assertPost(t, posts[0], blogposts.Post{
Title: "Post 1",
Description: "Description 1",
Tags: []string{"tdd", "go"},
})
}
```

Expand Down Expand Up @@ -716,19 +716,19 @@ Tags: rust, borrow-checker
B
L
M`
)
)
```

Add to our assertion like the others

```go
assertPost(t, posts[0], blogposts.Post{
Title: "Post 1",
Description: "Description 1",
Tags: []string{"tdd", "go"},
Body: `Hello
Title: "Post 1",
Description: "Description 1",
Tags: []string{"tdd", "go"},
Body: `Hello
World`,
})
})
```

## Try to run the test
Expand Down Expand Up @@ -844,9 +844,9 @@ If you wish to try out the code "for real":

```go
import (
blogposts "github.com/quii/fstest-spike"
"log"
"os"
blogposts "github.com/quii/fstest-spike"
"log"
"os"
)

func main() {
Expand Down
26 changes: 13 additions & 13 deletions revisiting-arrays-and-slices-with-generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,22 +396,22 @@ Again, because it takes a generic type, we can re-use it in many ways

```go
type Person struct {
Name string
Name string
}

t.Run("Find the best programmer", func(t *testing.T) {
people := []Person{
Person{Name: "Kent Beck"},
Person{Name: "Martin Fowler"},
Person{Name: "Chris James"},
}

king, found := Find(people, func(p Person) bool {
return strings.Contains(p.Name, "Chris")
})

AssertTrue(t, found)
AssertEqual(t, king, Person{Name: "Chris James"})
people := []Person{
Person{Name: "Kent Beck"},
Person{Name: "Martin Fowler"},
Person{Name: "Chris James"},
}

king, found := Find(people, func(p Person) bool {
return strings.Contains(p.Name, "Chris")
})

AssertTrue(t, found)
AssertEqual(t, king, Person{Name: "Chris James"})
})
```

Expand Down

0 comments on commit c9a369d

Please sign in to comment.