(t *testing.T)
| 101 | } |
| 102 | |
| 103 | func TestUpdateAlreadyUpToDate_JSON(t *testing.T) { |
| 104 | f, stdout, _ := newTestFactory(t) |
| 105 | |
| 106 | cmd := NewCmdUpdate(f) |
| 107 | cmd.SetArgs([]string{"--json"}) |
| 108 | |
| 109 | origFetch := fetchLatest |
| 110 | fetchLatest = func() (string, error) { return "1.0.0", nil } |
| 111 | defer func() { fetchLatest = origFetch }() |
| 112 | |
| 113 | origVersion := currentVersion |
| 114 | currentVersion = func() string { return "1.0.0" } |
| 115 | defer func() { currentVersion = origVersion }() |
| 116 | |
| 117 | err := cmd.Execute() |
| 118 | if err != nil { |
| 119 | t.Fatalf("unexpected error: %v", err) |
| 120 | } |
| 121 | |
| 122 | out := stdout.String() |
| 123 | if !strings.Contains(out, `"action": "already_up_to_date"`) { |
| 124 | t.Errorf("expected already_up_to_date in JSON output, got: %s", out) |
| 125 | } |
| 126 | if !strings.Contains(out, `"ok": true`) { |
| 127 | t.Errorf("expected ok:true in JSON output, got: %s", out) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | func TestUpdateAlreadyUpToDate_Human(t *testing.T) { |
| 132 | f, _, stderr := newTestFactory(t) |
nothing calls this directly
no test coverage detected