(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestFormat(t *testing.T) { |
| 15 | tests := []struct { |
| 16 | doc string |
| 17 | f Format |
| 18 | isJSON bool |
| 19 | isTable bool |
| 20 | template string |
| 21 | }{ |
| 22 | { |
| 23 | doc: "json format", |
| 24 | f: "json", |
| 25 | isJSON: true, |
| 26 | isTable: false, |
| 27 | template: JSONFormat, |
| 28 | }, |
| 29 | { |
| 30 | doc: "empty table format (no template)", |
| 31 | f: "table", |
| 32 | isJSON: false, |
| 33 | isTable: true, |
| 34 | template: "", |
| 35 | }, |
| 36 | { |
| 37 | doc: "table with escaped tabs", |
| 38 | f: "table {{.Field}}\\t{{.Field2}}", |
| 39 | isJSON: false, |
| 40 | isTable: true, |
| 41 | template: "{{.Field}}\t{{.Field2}}", |
| 42 | }, |
| 43 | { |
| 44 | doc: "table with raw string", |
| 45 | f: `table {{.Field}}\t{{.Field2}}`, |
| 46 | isJSON: false, |
| 47 | isTable: true, |
| 48 | template: "{{.Field}}\t{{.Field2}}", |
| 49 | }, |
| 50 | { |
| 51 | doc: "other format", |
| 52 | f: "other", |
| 53 | isJSON: false, |
| 54 | isTable: false, |
| 55 | template: "other", |
| 56 | }, |
| 57 | { |
| 58 | doc: "other with spaces", |
| 59 | f: " other ", |
| 60 | isJSON: false, |
| 61 | isTable: false, |
| 62 | template: "other", |
| 63 | }, |
| 64 | { |
| 65 | doc: "other with newline preserved", |
| 66 | f: " other\n ", |
| 67 | isJSON: false, |
| 68 | isTable: false, |
| 69 | template: "other\n", |
| 70 | }, |
| 71 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…