| 82 | } |
| 83 | |
| 84 | func TestParseSpec(t *testing.T) { |
| 85 | for i, tt := range newSpecTests { |
| 86 | s, err := newRoute(tt.raw, []string{}) |
| 87 | if tt.spec != nil { |
| 88 | if err != nil { |
| 89 | t.Errorf("Test %d, error:\n%s\n", i, err) |
| 90 | continue |
| 91 | } |
| 92 | if !reflect.DeepEqual(s, tt.spec) { |
| 93 | t.Errorf("Test %d, expecting:\n%s\nGot:\n%s\n", i, tt.spec, s) |
| 94 | continue |
| 95 | } |
| 96 | } else if tt.err != "" { |
| 97 | if err == nil { |
| 98 | t.Errorf("Test %d, expected error:\n%s\n", i, tt.err) |
| 99 | continue |
| 100 | } |
| 101 | if !within(tt.err, err) { |
| 102 | t.Errorf( |
| 103 | "Test %d, expected error:\n%s\nGot error:%s\n", |
| 104 | i, |
| 105 | tt.err, |
| 106 | err, |
| 107 | ) |
| 108 | continue |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | func TestForwardEndpoint(t *testing.T) { |
| 115 | f, err := newForwardEndpoint("http://foo") |