(t *testing.T)
| 95 | } |
| 96 | |
| 97 | func TestPreHash(t *testing.T) { |
| 98 | buf := []byte("github.com/OpenListTeam/OpenList") |
| 99 | f := &stream.FileStream{ |
| 100 | Obj: &model.Object{ |
| 101 | Size: int64(len(buf)), |
| 102 | }, |
| 103 | Reader: io.NopCloser(bytes.NewReader(buf)), |
| 104 | } |
| 105 | prevAutoMemoryLimit := conf.AutoMemoryLimit |
| 106 | prevMaxBlockLimit := conf.MaxBlockLimit |
| 107 | t.Cleanup(func() { |
| 108 | conf.AutoMemoryLimit = prevAutoMemoryLimit |
| 109 | conf.MaxBlockLimit = prevMaxBlockLimit |
| 110 | }) |
| 111 | conf.AutoMemoryLimit = 0 |
| 112 | conf.MaxBlockLimit = 15 |
| 113 | |
| 114 | const hashSize int64 = 20 |
| 115 | reader, _ := f.RangeRead(http_range.Range{Start: 0, Length: hashSize}) |
| 116 | preHash, _ := utils.HashReader(utils.SHA1, reader) |
| 117 | if preHash == "" { |
| 118 | t.Error("preHash is empty") |
| 119 | } |
| 120 | tmpF, fullHash, _ := stream.CacheFullAndHash(f, nil, utils.SHA1) |
| 121 | fmt.Println(fullHash) |
| 122 | fileFullHash, _ := utils.HashFile(utils.SHA1, tmpF) |
| 123 | fmt.Println(fileFullHash) |
| 124 | if fullHash != fileFullHash { |
| 125 | t.Errorf("fullHash and fileFullHash should match: fullHash=%s fileFullHash=%s", fullHash, fileFullHash) |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | func TestStreamSectionReader(t *testing.T) { |
| 130 | buf := make([]byte, 8<<10) |
nothing calls this directly
no test coverage detected