gogcli-mcp 2.0.0 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -76,4 +76,69 @@ describe('runOrDiagnose', () => {
76
76
  expect(result.content[0].text).toBe('Error: Doc not found');
77
77
  expect(result.content[0].text).not.toContain('gog_auth_add');
78
78
  });
79
+
80
+ it('appends transient-retry hint on 429 error', async () => {
81
+ vi.mocked(runner.run)
82
+ .mockRejectedValueOnce(new Error('Request failed with status 429'))
83
+ .mockResolvedValueOnce('user@gmail.com');
84
+ const result = await runOrDiagnose(['sheets', 'update', 'abc', 'A1'], {});
85
+ expect(result.content[0].text).toContain('transient');
86
+ expect(result.content[0].text).toContain('Retry');
87
+ });
88
+
89
+ it('appends transient-retry hint on 500/502/503/504 errors', async () => {
90
+ for (const status of [500, 502, 503, 504]) {
91
+ vi.clearAllMocks();
92
+ vi.mocked(runner.run)
93
+ .mockRejectedValueOnce(new Error(`Request failed with status ${status}`))
94
+ .mockResolvedValueOnce('user@gmail.com');
95
+ const result = await runOrDiagnose(['sheets', 'update', 'abc', 'A1'], {});
96
+ expect(result.content[0].text, `status ${status}`).toContain('transient');
97
+ }
98
+ });
99
+
100
+ it('appends transient-retry hint on quota/rateLimit errors', async () => {
101
+ for (const msg of ['Quota exceeded', 'rateLimitExceeded', 'userRateLimitExceeded']) {
102
+ vi.clearAllMocks();
103
+ vi.mocked(runner.run)
104
+ .mockRejectedValueOnce(new Error(msg))
105
+ .mockResolvedValueOnce('user@gmail.com');
106
+ const result = await runOrDiagnose(['sheets', 'update', 'abc', 'A1'], {});
107
+ expect(result.content[0].text, msg).toContain('transient');
108
+ }
109
+ });
110
+
111
+ it('appends transient-retry hint on DEADLINE_EXCEEDED error', async () => {
112
+ vi.mocked(runner.run)
113
+ .mockRejectedValueOnce(new Error('DEADLINE_EXCEEDED: context deadline exceeded'))
114
+ .mockResolvedValueOnce('user@gmail.com');
115
+ const result = await runOrDiagnose(['sheets', 'update', 'abc', 'A1'], {});
116
+ expect(result.content[0].text).toContain('transient');
117
+ });
118
+
119
+ it('does not append transient hint on 404 error', async () => {
120
+ vi.mocked(runner.run)
121
+ .mockRejectedValueOnce(new Error('Request failed with status 404'))
122
+ .mockResolvedValueOnce('user@gmail.com');
123
+ const result = await runOrDiagnose(['sheets', 'get', 'abc', 'A1'], {});
124
+ expect(result.content[0].text).not.toContain('transient');
125
+ });
126
+
127
+ it('does not append transient hint on auth (401) error', async () => {
128
+ vi.mocked(runner.run)
129
+ .mockRejectedValueOnce(new Error('Request failed with status 401'))
130
+ .mockResolvedValueOnce('user@gmail.com');
131
+ const result = await runOrDiagnose(['docs', 'cat', 'abc'], {});
132
+ expect(result.content[0].text).toContain('gog_auth_add');
133
+ expect(result.content[0].text).not.toContain('transient');
134
+ });
135
+
136
+ it('keeps transient hint when auth list also fails', async () => {
137
+ vi.mocked(runner.run)
138
+ .mockRejectedValueOnce(new Error('Request failed with status 503'))
139
+ .mockRejectedValueOnce(new Error('auth list failed'));
140
+ const result = await runOrDiagnose(['sheets', 'update', 'abc', 'A1'], {});
141
+ expect(result.content[0].text).toContain('transient');
142
+ expect(result.content[0].text).not.toContain('Configured accounts');
143
+ });
79
144
  });