(t *testing.T)
| 28 | } |
| 29 | |
| 30 | func TestSplitWriter(t *testing.T) { |
| 31 | dir := t.TempDir() |
| 32 | |
| 33 | tests := []struct { |
| 34 | name string // test name |
| 35 | fname string // fname to write |
| 36 | maxsize, bufsize int // splitWriter parameters |
| 37 | data string // data to write in fname |
| 38 | previous map[string]string // existing splits and their content |
| 39 | want map[string]int // files we want after the close and their size |
| 40 | }{ |
| 41 | { |
| 42 | name: "just line feeds", |
| 43 | fname: "just-line-feed", |
| 44 | maxsize: 3, bufsize: 2, |
| 45 | data: "\n\n\n\n", |
| 46 | want: map[string]int{ |
| 47 | "just-line-feed-part-1": 3, |
| 48 | "just-line-feed-part-2": 1, |
| 49 | }, |
| 50 | }, |
| 51 | { |
| 52 | name: "no line feeds", |
| 53 | fname: "no-line-feeds", |
| 54 | maxsize: 4, bufsize: 2, |
| 55 | data: "0123456789abcdefghijklmnopqrstuvwxyz", |
| 56 | want: map[string]int{ |
| 57 | "no-line-feeds": 36, |
| 58 | }, |
| 59 | }, |
| 60 | { |
| 61 | name: "small file", |
| 62 | fname: "smallfile", |
| 63 | maxsize: 12, bufsize: 4, |
| 64 | data: "test", |
| 65 | want: map[string]int{ |
| 66 | "smallfile": 4, |
| 67 | }, |
| 68 | }, |
| 69 | { |
| 70 | name: "big file no split", |
| 71 | fname: "big-file-no-split", |
| 72 | maxsize: 12, bufsize: 4, |
| 73 | data: "01234567890123", |
| 74 | want: map[string]int{ |
| 75 | "big-file-no-split": 14, |
| 76 | }, |
| 77 | }, |
| 78 | { |
| 79 | name: "big file 1 split", |
| 80 | fname: "big-file-1-split", |
| 81 | maxsize: 12, bufsize: 4, |
| 82 | data: "012\n34567890123", |
| 83 | want: map[string]int{ |
| 84 | "big-file-1-split-part-1": 4, |
| 85 | "big-file-1-split-part-2": 11, |
| 86 | }, |
| 87 | }, |
nothing calls this directly
no test coverage detected