MCPcopy Index your code
hub / github.com/perkeep/perkeep / TestHandlerRightRef

Function TestHandlerRightRef

internal/video/thumbnail/handler_test.go:47–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

45}
46
47func TestHandlerRightRef(t *testing.T) {
48 b := test.Blob{Contents: "Foo"}
49 storage := new(test.Fetcher)
50 ref, err := schema.WriteFileFromReader(context.Background(), storage, "", b.Reader())
51 if err != nil {
52 t.Fatal(err)
53 }
54 if err != nil {
55 t.Fatal(err)
56 }
57
58 ts := httptest.NewServer(createVideothumbnailHandler(ref, storage))
59 defer ts.Close()
60
61 resp, err := http.Get(ts.URL + "/" + ref.String())
62
63 if err != nil {
64 t.Fatal(err)
65 }
66 if resp.StatusCode != 200 {
67 t.Fatalf("expected 200 status: %v", resp)
68 }
69 content, err := io.ReadAll(resp.Body)
70 if err != nil {
71 t.Fatal(err)
72 }
73 if string(content) != b.Contents {
74 t.Errorf("excepted handler to serve data")
75 }
76}

Callers

nothing calls this directly

Calls 9

ReaderMethod · 0.95
WriteFileFromReaderFunction · 0.92
FatalMethod · 0.80
ReadAllMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.65
FatalfMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected