-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
36 lines (32 loc) · 884 Bytes
/
main_test.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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
// this is where we make a fake struct to replace a real bigquery config
type fakebqclient struct {
context string
client string
}
// this is a fake bigquery method that will always return what we want
func (bq fakebqclient) getDatasets() string {
return "hello i am a fake list of datasets"
}
func TestEnsureDataset(t *testing.T) {
bq := BQClient{
fakebqclient{
client: "mooclient",
context: "moocontext",
},
}
datasetlist := bq.ensureDataset()
assert.Equal(t, "hello i am a fake list of datasets", datasetlist, "not using the mocked method")
bq2 := BQClient{
BQClientinterface: BQClientStruct{
client: "mooclient",
context: "moocontext",
},
}
realdatasetlist := bq2.ensureDataset()
assert.Equal(t, "real list of datasets", realdatasetlist, "not using the mocked method")
}