MCPcopy
hub / github.com/perkeep/perkeep / TestParseMetaRow

Function TestParseMetaRow

pkg/blobserver/blobpacked/blobpacked_test.go:86–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

84}
85
86func TestParseMetaRow(t *testing.T) {
87 cases := []struct {
88 in string
89 want meta
90 err bool
91 }{
92 {in: "123 sx", err: true},
93 {in: "-123 s", err: true},
94 {in: "", err: true},
95 {in: "1 ", err: true},
96 {in: " ", err: true},
97 {in: "123 x", err: true},
98 {in: "123 l", err: true},
99 {in: "123 sha1-f1d2d2f924e986ac86fdf7b36c94bcdf32beec15", err: true},
100 {in: "123 notaref 12", err: true},
101 {in: "123 sha1-f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 42 extra", err: true},
102 {in: "123 sha1-f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 42 ", err: true},
103 {in: "123 sha1-f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 42", want: meta{
104 exists: true,
105 size: 123,
106 largeRef: blob.MustParse("sha1-f1d2d2f924e986ac86fdf7b36c94bcdf32beec15"),
107 largeOff: 42,
108 }},
109 }
110 for _, tt := range cases {
111 got, err := parseMetaRow([]byte(tt.in))
112 if (err != nil) != tt.err {
113 t.Errorf("For %q error = %v; want-err? = %v", tt.in, err, tt.err)
114 continue
115 }
116 if tt.err {
117 continue
118 }
119 if got != tt.want {
120 t.Errorf("For %q, parseMetaRow = %+v; want %+v", tt.in, got, tt.want)
121 }
122 }
123}
124
125func wantNumLargeBlobs(want int) func(*packTest) {
126 return func(pt *packTest) { pt.wantLargeBlobs = want }

Callers

nothing calls this directly

Calls 2

MustParseFunction · 0.92
parseMetaRowFunction · 0.85

Tested by

no test coverage detected