@@ -4,23 +4,23 @@ import { expect } from "chai";
4
4
import * as gcp from "../../../gcp/frameworks" ;
5
5
import * as repo from "../../../init/features/frameworks/repo" ;
6
6
import * as poller from "../../../operation-poller" ;
7
- import { createStack , getOrCreateStack } from "../../../init/features/frameworks/index" ;
7
+ import { createBackend , getOrCreateBackend } from "../../../init/features/frameworks/index" ;
8
8
import { FirebaseError } from "../../../error" ;
9
9
10
10
describe ( "operationsConverter" , ( ) => {
11
11
const sandbox : sinon . SinonSandbox = sinon . createSandbox ( ) ;
12
12
13
13
let pollOperationStub : sinon . SinonStub ;
14
- let createStackStub : sinon . SinonStub ;
15
- let getStackStub : sinon . SinonStub ;
14
+ let createBackendStub : sinon . SinonStub ;
15
+ let getBackendStub : sinon . SinonStub ;
16
16
let linkGitHubRepositoryStub : sinon . SinonStub ;
17
17
18
18
beforeEach ( ( ) => {
19
19
pollOperationStub = sandbox
20
20
. stub ( poller , "pollOperation" )
21
21
. throws ( "Unexpected pollOperation call" ) ;
22
- createStackStub = sandbox . stub ( gcp , "createStack " ) . throws ( "Unexpected createStack call" ) ;
23
- getStackStub = sandbox . stub ( gcp , "getBackend" ) . throws ( "Unexpected getBackend call" ) ;
22
+ createBackendStub = sandbox . stub ( gcp , "createBackend " ) . throws ( "Unexpected createBackend call" ) ;
23
+ getBackendStub = sandbox . stub ( gcp , "getBackend" ) . throws ( "Unexpected getBackend call" ) ;
24
24
linkGitHubRepositoryStub = sandbox
25
25
. stub ( repo , "linkGitHubRepository" )
26
26
. throws ( "Unexpected getBackend call" ) ;
@@ -30,16 +30,16 @@ describe("operationsConverter", () => {
30
30
sandbox . verifyAndRestore ( ) ;
31
31
} ) ;
32
32
33
- describe ( "createStack " , ( ) => {
33
+ describe ( "createBackend " , ( ) => {
34
34
const projectId = "projectId" ;
35
35
const location = "us-central1" ;
36
- const stackId = "stackId " ;
36
+ const backendId = "backendId " ;
37
37
const op = {
38
- name : `projects/${ projectId } /locations/${ location } /stacks /${ stackId } ` ,
38
+ name : `projects/${ projectId } /locations/${ location } /backends /${ backendId } ` ,
39
39
done : true ,
40
40
} ;
41
- const completeStack = {
42
- name : `projects/${ projectId } /locations/${ location } /stacks /${ stackId } ` ,
41
+ const completeBackend = {
42
+ name : `projects/${ projectId } /locations/${ location } /backends /${ backendId } ` ,
43
43
labels : { } ,
44
44
createTime : "0" ,
45
45
updateTime : "1" ,
@@ -48,8 +48,8 @@ describe("operationsConverter", () => {
48
48
const setup = {
49
49
frameworks : {
50
50
region : location ,
51
- serviceName : stackId ,
52
- existingStack : true ,
51
+ serviceName : backendId ,
52
+ existingBackend : true ,
53
53
deployMethod : "github" ,
54
54
} ,
55
55
} ;
@@ -59,46 +59,46 @@ describe("operationsConverter", () => {
59
59
createTime : "0" ,
60
60
updateTime : "1" ,
61
61
} ;
62
- const stackInput = {
62
+ const backendInput = {
63
63
codebase : {
64
64
repository : cloudBuildConnRepo . name ,
65
65
rootDirectory : "/" ,
66
66
} ,
67
67
labels : { } ,
68
68
} ;
69
- it ( "should createStack " , async ( ) => {
70
- createStackStub . resolves ( op ) ;
71
- pollOperationStub . resolves ( completeStack ) ;
69
+ it ( "should createBackend " , async ( ) => {
70
+ createBackendStub . resolves ( op ) ;
71
+ pollOperationStub . resolves ( completeBackend ) ;
72
72
73
- await createStack ( projectId , location , stackInput , stackId ) ;
73
+ await createBackend ( projectId , location , backendInput , backendId ) ;
74
74
75
- expect ( createStackStub ) . to . be . calledWith ( projectId , location , stackInput ) ;
75
+ expect ( createBackendStub ) . to . be . calledWith ( projectId , location , backendInput ) ;
76
76
} ) ;
77
77
78
- it ( "should return a stack , if user wants use the exiting stack " , async ( ) => {
79
- getStackStub . resolves ( completeStack ) ;
78
+ it ( "should return a backend , if user wants use the exiting backend " , async ( ) => {
79
+ getBackendStub . resolves ( completeBackend ) ;
80
80
81
- const result = await getOrCreateStack ( "projectId" , setup ) ;
81
+ const result = await getOrCreateBackend ( "projectId" , setup ) ;
82
82
83
- expect ( result ) . to . deep . equal ( completeStack ) ;
84
- expect ( getStackStub . calledOnceWithExactly ( projectId , location , stackId ) ) . to . be . true ;
83
+ expect ( result ) . to . deep . equal ( completeBackend ) ;
84
+ expect ( getBackendStub . calledOnceWithExactly ( projectId , location , backendId ) ) . to . be . true ;
85
85
} ) ;
86
86
87
- it ( "should create a new stack , if stack doesn't exist" , async ( ) => {
88
- const newStackId = "newStackId " ;
89
- const newPath = `projects/${ projectId } /locations/${ location } /stacks /${ newStackId } ` ;
90
- setup . frameworks . serviceName = newStackId ;
87
+ it ( "should create a new backend , if backend doesn't exist" , async ( ) => {
88
+ const newBackendId = "newBackendId " ;
89
+ const newPath = `projects/${ projectId } /locations/${ location } /backends /${ newBackendId } ` ;
90
+ setup . frameworks . serviceName = newBackendId ;
91
91
op . name = newPath ;
92
- completeStack . name = newPath ;
93
- getStackStub . throws ( new FirebaseError ( "error" , { status : 404 } ) ) ;
92
+ completeBackend . name = newPath ;
93
+ getBackendStub . throws ( new FirebaseError ( "error" , { status : 404 } ) ) ;
94
94
linkGitHubRepositoryStub . resolves ( cloudBuildConnRepo ) ;
95
- createStackStub . resolves ( op ) ;
96
- pollOperationStub . resolves ( completeStack ) ;
95
+ createBackendStub . resolves ( op ) ;
96
+ pollOperationStub . resolves ( completeBackend ) ;
97
97
98
- const result = await getOrCreateStack ( projectId , setup ) ;
98
+ const result = await getOrCreateBackend ( projectId , setup ) ;
99
99
100
- expect ( result ) . to . deep . equal ( completeStack ) ;
101
- expect ( createStackStub ) . to . be . calledWith ( projectId , location , stackInput ) ;
100
+ expect ( result ) . to . deep . equal ( completeBackend ) ;
101
+ expect ( createBackendStub ) . to . be . calledWith ( projectId , location , backendInput ) ;
102
102
} ) ;
103
103
} ) ;
104
104
} ) ;
0 commit comments