(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func TestPathReplace(t *testing.T) { |
| 9 | cases := []struct { |
| 10 | Orig, ExpPath, ExpRawPath []byte |
| 11 | Key, Val string |
| 12 | ExpectErr bool |
| 13 | }{ |
| 14 | { |
| 15 | Orig: []byte("/{bucket}/{key+}"), |
| 16 | ExpPath: []byte("/123/{key+}"), |
| 17 | ExpRawPath: []byte("/123/{key+}"), |
| 18 | Key: "bucket", Val: "123", |
| 19 | }, |
| 20 | { |
| 21 | Orig: []byte("/{bucket}/{key+}"), |
| 22 | ExpPath: []byte("/{bucket}/abc"), |
| 23 | ExpRawPath: []byte("/{bucket}/abc"), |
| 24 | Key: "key", Val: "abc", |
| 25 | }, |
| 26 | { |
| 27 | Orig: []byte("/{bucket}/{key+}"), |
| 28 | ExpPath: []byte("/{bucket}/a/b/c"), |
| 29 | ExpRawPath: []byte("/{bucket}/a/b/c"), |
| 30 | Key: "key", Val: "a/b/c", |
| 31 | }, |
| 32 | { |
| 33 | Orig: []byte("/{bucket}/{key+}"), |
| 34 | ExpPath: []byte("/1/2/3/{key+}"), |
| 35 | ExpRawPath: []byte("/1%2F2%2F3/{key+}"), |
| 36 | Key: "bucket", Val: "1/2/3", |
| 37 | }, |
| 38 | { |
| 39 | Orig: []byte("/{bucket}/{key+}"), |
| 40 | ExpPath: []byte("/reallylongvaluegoesheregrowingarray/{key+}"), |
| 41 | ExpRawPath: []byte("/reallylongvaluegoesheregrowingarray/{key+}"), |
| 42 | Key: "bucket", Val: "reallylongvaluegoesheregrowingarray", |
| 43 | }, |
| 44 | { |
| 45 | Orig: []byte("/{namespace}/{name}"), |
| 46 | ExpPath: []byte("/{namespace}/value"), |
| 47 | ExpRawPath: []byte("/{namespace}/value"), |
| 48 | Key: "name", Val: "value", |
| 49 | }, |
| 50 | { |
| 51 | Orig: []byte("/{name}/{namespace}"), |
| 52 | ExpPath: []byte("/value/{namespace}"), |
| 53 | ExpRawPath: []byte("/value/{namespace}"), |
| 54 | Key: "name", Val: "value", |
| 55 | }, |
| 56 | { |
| 57 | Orig: []byte("/{namespace}/{name+}"), |
| 58 | Key: "nam", Val: "value", |
| 59 | ExpectErr: true, |
| 60 | }, |
| 61 | } |
| 62 | |
| 63 | var buffer [64]byte |
| 64 | |
| 65 | for i, c := range cases { |
nothing calls this directly
no test coverage detected