Skip to content

Commit 369c402

Browse files
committed
updates error handling and tests
1 parent 4ebc27b commit 369c402

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

src/commands/functions-list.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,8 @@ export const command = new Command("functions:list")
2424
projectId,
2525
} as args.Context;
2626

27-
let endpoints: backend.Endpoint[] = [];
28-
try {
29-
const existing = await backend.existingBackend(context);
30-
endpoints = backend.allEndpoints(existing);
31-
} catch (err: any) {
32-
logger.debug(`Failed to list functions:`, err);
33-
logger.warn(err.message);
34-
}
27+
const existing = await backend.existingBackend(context);
28+
const endpoints = backend.allEndpoints(existing);
3529

3630
endpoints.sort(backend.compareFunctions);
3731

src/deploy/functions/backend.spec.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { FirebaseError } from "../../error";
55
import * as args from "./args";
66
import * as backend from "./backend";
77
import * as gcf from "../../gcp/cloudfunctions";
8-
import * as gcfV2 from "../../gcp/cloudfunctionsv2";
98
import * as runv2 from "../../gcp/runv2";
109
import * as utils from "../../utils";
1110
import * as projectConfig from "../../functions/projectConfig";
@@ -90,20 +89,17 @@ describe("Backend", () => {
9089

9190
describe("existing backend", () => {
9291
let listAllFunctions: sinon.SinonStub;
93-
let listAllFunctionsV2: sinon.SinonStub;
9492
let listServices: sinon.SinonStub;
9593
let logLabeledWarning: sinon.SinonSpy;
9694

9795
beforeEach(() => {
9896
listAllFunctions = sinon.stub(gcf, "listAllFunctions").rejects("Unexpected call");
99-
listAllFunctionsV2 = sinon.stub(gcfV2, "listAllFunctions").rejects("Unexpected v2 call");
100-
listServices = sinon.stub(runv2, "listServices").resolves([]);
97+
listServices = sinon.stub(runv2, "listServices").rejects("Unexpected call");
10198
logLabeledWarning = sinon.spy(utils, "logLabeledWarning");
10299
});
103100

104101
afterEach(() => {
105102
listAllFunctions.restore();
106-
listAllFunctionsV2.restore();
107103
listServices.restore();
108104
logLabeledWarning.restore();
109105
});
@@ -162,6 +158,7 @@ describe("Backend", () => {
162158
functions: [],
163159
unreachable: [],
164160
});
161+
listServices.onFirstCall().resolves([]);
165162
listServices.throws(new FirebaseError("HTTP Error: 500, Internal Error", { status: 500 }));
166163

167164
const context = newContext();
@@ -190,25 +187,6 @@ describe("Backend", () => {
190187
expect(have).to.deep.equal(backend.of({ ...ENDPOINT, httpsTrigger: {} }));
191188
});
192189

193-
it("should read v1 functions only when user is not allowlisted for v2", async () => {
194-
listAllFunctions.onFirstCall().resolves({
195-
functions: [
196-
{
197-
...HAVE_CLOUD_FUNCTION,
198-
httpsTrigger: {},
199-
},
200-
],
201-
unreachable: [],
202-
});
203-
listAllFunctionsV2.throws(
204-
new FirebaseError("HTTP Error: 404, Method not found", { status: 404 }),
205-
);
206-
207-
const have = await backend.existingBackend(newContext());
208-
209-
expect(have).to.deep.equal(backend.of({ ...ENDPOINT, httpsTrigger: {} }));
210-
});
211-
212190
it("should read v2 functions when enabled", async () => {
213191
listAllFunctions.onFirstCall().resolves({
214192
functions: [],

0 commit comments

Comments
 (0)