-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstruct_test.go
More file actions
47 lines (33 loc) · 1.33 KB
/
Copy pathstruct_test.go
File metadata and controls
47 lines (33 loc) · 1.33 KB
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
package htmldump_test
import (
"bytes"
"fmt"
"strings"
"testing"
"github.com/oslyak/htmldump"
"github.com/stretchr/testify/require"
)
func TestDumpStruct(t *testing.T) {
t.Parallel()
filter := newFilterAccounts()
// dump.ToHTMLAndOpen(`/tmp/dump_struct_test.html`, filter, &filter)
buffer := bytes.NewBuffer([]byte{})
err := htmldump.ToHTML(buffer, filter)
require.NoError(t, err)
table := extractHTMLTable(t, buffer.String())
table = removeStyle(t, table)
require.Contains(t, table, `<caption>struct filterAccounts</caption>`)
require.Contains(t, table, `<tr><th>Field</th><th>Type</th><th>Value</th></tr>`)
expect := fmt.Sprintf("<tr><td>OwnerID</td><td>int64</td><td>%d</td></tr><tr>", filter.OwnerID)
require.Contains(t, table, expect)
expect = fmt.Sprintf("<tr><td>ExchangeID</td><td>int64</td><td>%d</td></tr><tr>", filter.ExchangeID)
require.Contains(t, table, expect)
expect = fmt.Sprintf(`<tr><td>EmptyPointer</td><td>*filter</td><td>%s</td></tr>`, htmldump.NULL)
require.Contains(t, table, expect)
strBuilder := strings.Builder{}
strBuilder.WriteString(`<tr><td>order</td><td>order</td><td></td></tr>`)
strBuilder.WriteString(`<tr><td>Column</td><td>string</td><td>`)
strBuilder.WriteString(filter.filter.order.Column)
strBuilder.WriteString("</td></tr>")
require.Contains(t, table, strBuilder.String())
}