MCPcopy Index your code
hub / github.com/dunglas/httpsfv / TestMarshalKey

Function TestMarshalKey

key_test.go:8–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestMarshalKey(t *testing.T) {
9 t.Parallel()
10
11 data := []struct {
12 in string
13 expected string
14 valid bool
15 }{
16 {"f1oo", "f1oo", true},
17 {"*foo0", "*foo0", true},
18 {"", "", false},
19 {"1foo", "", false},
20 {"fOo", "", false},
21 }
22
23 var b strings.Builder
24
25 for _, d := range data {
26 b.Reset()
27
28 err := marshalKey(&b, d.in)
29 if d.valid && err != nil {
30 t.Errorf("error not expected for %v, got %v", d.in, err)
31 } else if !d.valid && err == nil {
32 t.Errorf("error expected for %v, got %v", d.in, err)
33 }
34
35 if b.String() != d.expected {
36 t.Errorf("got %v; want %v", b.String(), d.expected)
37 }
38 }
39}
40
41func TestParseKey(t *testing.T) {
42 t.Parallel()

Callers

nothing calls this directly

Calls 1

marshalKeyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…