(t *testing.T)
| 117 | fetcher := &HTTPFetcher{} |
| 118 | _, err = fetcher.FetchStats(cfg) |
| 119 | require.Error(t, err) |
| 120 | require.Contains(t, err.Error(), "no selected grandmaster") |
| 121 | } |
| 122 | |
| 123 | func TestFetchStatsNoSelectedGMDescribesEachGM(t *testing.T) { |
| 124 | sampleResp := ` |
| 125 | [ |
| 126 | {"gm_address": "127.0.0.1", "selected": false, "gm_present": 0, "error": "timed out waiting for response"}, |
| 127 | {"gm_address": "127.0.0.2", "selected": false, "gm_present": 1, "error": "", "cf_rx": -250, "cf_tx": 100, |
| 128 | "clock_quality": {"clock_class": 6, "clock_accuracy": 33}}, |
| 129 | {"gm_address": "127.0.0.3", "selected": false, "gm_present": 1, "error": "", |
| 130 | "clock_quality": {"clock_class": 248, "clock_accuracy": 254}}, |
| 131 | {"gm_address": "127.0.0.4", "selected": false, "gm_present": 1, "error": "", |
| 132 | "clock_quality": {"clock_class": 248, "clock_accuracy": 49}} |
| 133 | ] |
| 134 | ` |
| 135 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 136 | fmt.Fprintln(w, sampleResp) |
| 137 | })) |
| 138 | defer ts.Close() |
| 139 | surl, err := url.Parse(ts.URL) |
| 140 | require.NoError(t, err) |
| 141 | cfg := &Config{PTPClientAddress: fmt.Sprintf("%s:%s", surl.Hostname(), surl.Port())} |
| 142 | fetcher := &HTTPFetcher{} |
nothing calls this directly
no test coverage detected
searching dependent graphs…