-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclient_reader_test.go
50 lines (41 loc) · 951 Bytes
/
client_reader_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package herschel
import (
"testing"
)
func TestReading(t *testing.T) {
spreadsheetID := createNewSpreadsheet(t)
c := newTestClient(t)
// Create test sheet
sheetTitle := t.Name()
if err := c.RecreateSheet(spreadsheetID, sheetTitle); err != nil {
t.Fatal(err)
}
table := NewTable(2, 1)
table.PutValue(0, 0, "Hello")
table.PutValue(1, 0, "World")
if err := c.WriteTable(spreadsheetID, sheetTitle, table); err != nil {
t.Fatal(err)
}
t.Run("Read", func(t *testing.T) {
_, err := c.Read(spreadsheetID, sheetTitle)
if err != nil {
t.Fatal(err)
}
})
t.Run("ReadTable", func(t *testing.T) {
_, err := c.ReadTable(spreadsheetID, sheetTitle)
if err != nil {
t.Fatal(err)
}
})
t.Run("ListingSheets", func(t *testing.T) {
titles, err := c.SheetTitles(spreadsheetID)
if err != nil {
t.Fatal(err)
}
if len(titles) != 2 {
t.Log(titles)
t.Errorf("Expect 2 sheet titles, got %d", len(titles))
}
})
}