MCPcopy
hub / github.com/klauspost/compress / TestNameDecoderError

Function TestNameDecoderError

zip/reader_test.go:2012–2027  ·  view source on GitHub ↗

TestNameDecoderError verifies that an error returned by the decoder is propagated from NewReaderWithOptions.

(t *testing.T)

Source from the content-addressed store, hash-verified

2010// TestNameDecoderError verifies that an error returned by the decoder is
2011// propagated from NewReaderWithOptions.
2012func TestNameDecoderError(t *testing.T) {
2013 var buf bytes.Buffer
2014 zw := NewWriter(&buf)
2015 if _, err := zw.CreateHeader(&FileHeader{Name: "file.txt", Method: Store}); err != nil {
2016 t.Fatal(err)
2017 }
2018 if err := zw.Close(); err != nil {
2019 t.Fatal(err)
2020 }
2021
2022 wantErr := fmt.Errorf("decode failure")
2023 _, err := NewReaderWithOptions(bytes.NewReader(buf.Bytes()), int64(buf.Len()), ReaderOptions{NameDecoder: func(*FileHeader) error { return wantErr }})
2024 if err != wantErr {
2025 t.Errorf("NewReaderWithOptions err = %v, want %v", err, wantErr)
2026 }
2027}

Callers

nothing calls this directly

Calls 7

CreateHeaderMethod · 0.95
CloseMethod · 0.95
NewReaderWithOptionsFunction · 0.85
FatalMethod · 0.80
LenMethod · 0.80
NewWriterFunction · 0.70
BytesMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…