(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestEncodeAsMap(t *testing.T) { //nolint:tparallel |
| 14 | t.Parallel() |
| 15 | |
| 16 | ctx := context.TODO() |
| 17 | refTime := time.Date(2022, time.February, 15, 9, 51, 0, 0, time.UTC) |
| 18 | |
| 19 | cases := []struct { |
| 20 | Desc string |
| 21 | Input interface{} |
| 22 | Expected map[string]interface{} |
| 23 | }{ |
| 24 | { |
| 25 | "Encode basic types", |
| 26 | struct { |
| 27 | I int |
| 28 | F float64 |
| 29 | S string |
| 30 | B []byte |
| 31 | }{ |
| 32 | I: 1, |
| 33 | F: 1.2, |
| 34 | S: "string", |
| 35 | B: ([]byte)("bytes"), |
| 36 | }, |
| 37 | map[string]interface{}{ |
| 38 | "I": 1, |
| 39 | "F": 1.2, |
| 40 | "S": "string", |
| 41 | "B": ([]byte)("bytes"), |
| 42 | }, |
| 43 | }, |
| 44 | { |
| 45 | "Encode using struct tags", |
| 46 | struct { |
| 47 | I int `sqlite:"col_int"` |
| 48 | S string `sqlite:"col_string"` |
| 49 | }{ |
| 50 | I: 1, |
| 51 | S: "string value", |
| 52 | }, |
| 53 | map[string]interface{}{ |
| 54 | "col_int": 1, |
| 55 | "col_string": "string value", |
| 56 | }, |
| 57 | }, |
| 58 | { |
| 59 | "Ignore Private fields", |
| 60 | struct { |
| 61 | I int |
| 62 | s string |
| 63 | }{ |
| 64 | I: 1, |
| 65 | s: "string value", |
| 66 | }, |
| 67 | map[string]interface{}{ |
| 68 | "I": 1, |
| 69 | }, |
| 70 | }, |
nothing calls this directly
no test coverage detected