(t *testing.T)
| 86 | } |
| 87 | |
| 88 | func TestTrackCommandCompleted_ReportsFailure(t *testing.T) { |
| 89 | client := &recordingTelemetryClient{} |
| 90 | ctx := newTelemetryContext(client, "algolia indices list") |
| 91 | |
| 92 | trackCommandCompleted(ctx, &cobra.Command{Use: "list"}, exitError, errors.New("boom"), time.Second) |
| 93 | |
| 94 | if len(client.events) != 1 { |
| 95 | t.Fatalf("expected 1 event, got %d", len(client.events)) |
| 96 | } |
| 97 | props := client.events[0].props |
| 98 | if props["succeeded"] != false { |
| 99 | t.Errorf("succeeded = %v, want false", props["succeeded"]) |
| 100 | } |
| 101 | if props["exit_code"] != 1 { |
| 102 | t.Errorf("exit_code = %v, want 1", props["exit_code"]) |
| 103 | } |
| 104 | if props["error_class"] != "*errors.errorString" { |
| 105 | t.Errorf("error_class = %v, want *errors.errorString", props["error_class"]) |
| 106 | } |
| 107 | if props["user_cancelled"] != false { |
| 108 | t.Errorf("user_cancelled = %v, want false", props["user_cancelled"]) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | func TestPrintError(t *testing.T) { |
| 113 | cmd := &cobra.Command{} |
nothing calls this directly
no test coverage detected