MCPcopy
hub / github.com/fabiolb/fabio / TestBase

Function TestBase

cert/load_test.go:9–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestBase(t *testing.T) {
10 tests := []struct {
11 in, out, err string
12 }{
13 {"", "", ""},
14 {"http://foo.com/x/y", "http://foo.com/x", ""},
15 {"http://foo.com/x/y?p=q", "http://foo.com/x?p=q", ""},
16 }
17
18 for i, tt := range tests {
19 u, err := base(tt.in)
20 if err != nil {
21 if got, want := err.Error(), tt.err; got != want {
22 t.Errorf("%d: got %v want %v", i, got, want)
23 continue
24 }
25 }
26 if tt.err != "" {
27 t.Errorf("%d: got nil want %v", i, tt.err)
28 continue
29 }
30 if got, want := u, tt.out; got != want {
31 t.Errorf("%d: got %v want %v", i, got, want)
32 }
33 }
34}
35
36func TestReplaceSuffix(t *testing.T) {
37 if got, want := replaceSuffix("ab", "b", "c"), "ac"; got != want {

Callers

nothing calls this directly

Calls 2

baseFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected