-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (31 loc) · 994 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
// this is the interface type that will need to be mocked in tests
type BQClientinterface interface {
getDatasets() (string)
}
// this is the actual struct where I would construct a real bq client object, prolly using a build method
type BQClientStruct struct {
context string
client string
}
// this is the structure abstraction that we actually use in our code
type BQClient struct {
BQClientinterface BQClientinterface
}
// this is an example of a method that in real life would reach out to an external api so it would need to be mocked
func (bq BQClientStruct) getDatasets() string {
return "real list of datasets"
}
func main() {
bq := BQClient{
BQClientinterface: BQClientStruct{
client: "mooclient",
context: "moocontext",
},
}
bq.ensureDataset()
}
// this is an example of a method that we want to test that calls a method that calls an external api (CALLS!)
func (u *BQClient) ensureDataset() string {
return u.BQClientinterface.getDatasets()
}