(t *testing.T)
| 32 | ) |
| 33 | |
| 34 | func TestWriteFileMap(t *testing.T) { |
| 35 | m := NewFileMap("test-file") |
| 36 | r := &randReader{seed: 123, length: 5 << 20} |
| 37 | sr := new(stats.Receiver) |
| 38 | var buf bytes.Buffer |
| 39 | br, err := WriteFileMap(ctxbg, sr, m, io.TeeReader(r, &buf)) |
| 40 | if err != nil { |
| 41 | t.Fatal(err) |
| 42 | } |
| 43 | t.Logf("Got root file %v; %d blobs, %d bytes", br, sr.NumBlobs(), sr.SumBlobSize()) |
| 44 | sizes := sr.Sizes() |
| 45 | t.Logf("Sizes are %v", sizes) |
| 46 | |
| 47 | // TODO(bradfitz): these are fragile tests and mostly just a placeholder. |
| 48 | // Real tests to add: |
| 49 | // -- no "bytes" schema with a single "blobref" |
| 50 | // -- more seeds (including some that tickle the above) |
| 51 | // -- file reader reading back the root gets the same sha224 content back |
| 52 | // (will require keeping the full data in our stats receiver, not |
| 53 | // just the size) |
| 54 | // -- well-balanced tree |
| 55 | // -- nothing too big, nothing too small. |
| 56 | if g, w := br.String(), "sha224-4c6e23fe27b76bb61f433b5870b75828a4ab14d728333e1e201595e6"; g != w { |
| 57 | t.Errorf("root blobref = %v; want %v", g, w) |
| 58 | } |
| 59 | if g, w := sr.NumBlobs(), 84; g != w { |
| 60 | t.Errorf("num blobs = %v; want %v", g, w) |
| 61 | } |
| 62 | if g, w := sr.SumBlobSize(), int64(5253501); g != w { |
| 63 | t.Errorf("sum blob size = %v; want %v", g, w) |
| 64 | } |
| 65 | if g, w := sizes[len(sizes)-1], 262144; g != w { |
| 66 | t.Errorf("biggest blob is %d; want %d", g, w) |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | func TestWriteThenRead(t *testing.T) { |
| 71 | m := NewFileMap("test-file") |
nothing calls this directly
no test coverage detected