This file contains hidden or 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
$ tree -L 2 | |
. | |
├── CONTRIBUTING.md | |
├── Dockerfile | |
├── LICENSE | |
├── Makefile | |
├── README.md | |
├── app | |
│ ├── app.go | |
│ └── app_test.go |
This file contains hidden or 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
type Speak interface { | |
SayHello() string | |
} |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
) | |
type Speak interface { | |
SayHello() string | |
} |
This file contains hidden or 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
type English struct{} | |
func (e English) SayHello() string { | |
return "Hello" | |
} |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
) | |
type Speak interface { | |
SayHello() string | |
} |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
) | |
type Database interface { | |
Fetch(key string) (int, error) | |
} |
This file contains hidden or 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
type MockDB struct { | |
// FakeFetch is used to provide unique test case results | |
FakeFetch func(string) (int, error) | |
} | |
func (m *MockDB) Fetch(k string) (int, error) { | |
if m.FakeFetch != nil { | |
return m.FakeFetch(k) | |
} | |
return 0, nil |
This file contains hidden or 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
func TestIsOver9k(t *testing.T) { | |
t.Run("TestOver9000", func(t *testing.T) { | |
DB = &MockDB{ | |
FakeFetch: func(string) (int, error) { | |
return 9001, nil | |
}, | |
} | |
if !isOver9000() { | |
t.Errorf("Test did not return expected results") | |
} |
This file contains hidden or 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
$ tree -L 2 | |
. | |
├── CONTRIBUTING.md | |
├── Dockerfile | |
├── LICENSE | |
├── Makefile | |
├── README.md | |
├── app | |
│ ├── app.go | |
│ ├── app_test.go |
This file contains hidden or 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
package app | |
import ( | |
// imports go here | |
"github.com/madflojo/go-quick/config" | |
) | |
// Common errors returned by this app. | |
var ( | |
ErrShutdown = fmt.Errorf("application shutdown gracefully") |