(t *testing.T)
| 29 | } |
| 30 | |
| 31 | func TestFetchFile(t *testing.T) { |
| 32 | d := map[string][]byte{ |
| 33 | "0": []byte("abc"), |
| 34 | "3": []byte("def"), |
| 35 | } |
| 36 | |
| 37 | r := &mockReader{data: d} |
| 38 | |
| 39 | if b, err := FetchFile(r, "test", 0, 3); err != nil { |
| 40 | t.Errorf("expected no error, got %v", err) |
| 41 | } else if string(b) != "abc" { |
| 42 | t.Errorf("expected %s, got %s", "abc", string(b)) |
| 43 | } |
| 44 | |
| 45 | if b, err := FetchFile(r, "test", 0, 4); err != nil { |
| 46 | t.Errorf("expected no error, got %v", err) |
| 47 | } else if string(b[:3]) != "abc" { |
| 48 | t.Errorf("expected %s, got %s", "abc", string(b)) |
| 49 | } |
| 50 | |
| 51 | if b, err := FetchFile(r, "test", 3, 3); err != nil { |
| 52 | t.Errorf("expected no error, got %v", err) |
| 53 | } else if string(b) != "def" { |
| 54 | t.Errorf("expected %s, got %s", "def", string(b)) |
| 55 | } |
| 56 | |
| 57 | if b, err := FetchFile(r, "test", 31, 4); err == nil { |
| 58 | t.Errorf("expected error, got %s", string(b)) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | type mockReader struct { |
| 63 | data map[string][]byte |
nothing calls this directly
no test coverage detected