(t *testing.T)
| 41 | } |
| 42 | |
| 43 | func TestAPIDispatcher_StatusAndConfig(t *testing.T) { |
| 44 | t.Parallel() |
| 45 | d := NewAPIDispatcher(newTestAPI(), nil) |
| 46 | ctx := context.Background() |
| 47 | |
| 48 | body, err := d.Handle(ctx, "Status", nil) |
| 49 | if err != nil { |
| 50 | t.Fatalf("Status err: %v", err) |
| 51 | } |
| 52 | var st struct { |
| 53 | Running bool `json:"running"` |
| 54 | } |
| 55 | if err := json.Unmarshal(body, &st); err != nil { |
| 56 | t.Fatalf("decode status: %v body=%s", err, body) |
| 57 | } |
| 58 | |
| 59 | body, err = d.Handle(ctx, "Config", nil) |
| 60 | if err != nil { |
| 61 | t.Fatalf("Config err: %v", err) |
| 62 | } |
| 63 | var cfg struct { |
| 64 | Config string `json:"config"` |
| 65 | } |
| 66 | if err := json.Unmarshal(body, &cfg); err != nil { |
| 67 | t.Fatalf("decode config: %v", err) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | func TestAPIDispatcher_Usage(t *testing.T) { |
| 72 | t.Parallel() |
nothing calls this directly
no test coverage detected