1
1
import os from "os" ;
2
2
import path from "path" ;
3
+ import fs from "fs" ;
3
4
import shell from "shelljs" ;
4
5
import uuid from "uuid/v4" ;
5
6
import {
@@ -14,6 +15,7 @@ import {
14
15
import { createTempDir } from "./lib/ioUtil" ;
15
16
import { disableVerboseLogging , enableVerboseLogging } from "./logger" ;
16
17
import { BedrockFile } from "./types" ;
18
+ import { getVersionMessage } from "./lib/fileutils" ;
17
19
18
20
beforeAll ( ( ) => {
19
21
enableVerboseLogging ( ) ;
@@ -51,6 +53,7 @@ describe("Test updateVariableWithLocalEnv function", () => {
51
53
} ) ;
52
54
53
55
describe ( "Bedrock" , ( ) => {
56
+ const writeSpy = jest . spyOn ( fs , "writeFileSync" ) ;
54
57
test ( "valid helm configuration passes" , ( ) => {
55
58
const randomTmpDir = path . join ( os . tmpdir ( ) , uuid ( ) ) ;
56
59
shell . mkdir ( "-p" , randomTmpDir ) ;
@@ -82,9 +85,16 @@ describe("Bedrock", () => {
82
85
pathPrefix : "servicepath" ,
83
86
pathPrefixMajorVersion : "v1"
84
87
}
85
- }
88
+ } ,
89
+ version : "1.0"
86
90
} ;
87
91
write ( validBedrockYaml , randomTmpDir ) ;
92
+ const expectedFilePath = path . join ( randomTmpDir , "bedrock.yaml" ) ;
93
+ expect ( writeSpy ) . toBeCalledWith (
94
+ expectedFilePath ,
95
+ `${ getVersionMessage ( ) } \n` ,
96
+ "utf8"
97
+ ) ;
88
98
89
99
const bedrockConfig = Bedrock ( randomTmpDir ) ;
90
100
expect ( bedrockConfig ) . toBeTruthy ( ) ;
@@ -113,10 +123,18 @@ describe("Bedrock", () => {
113
123
}
114
124
}
115
125
}
116
- }
126
+ } ,
127
+ version : "1.0"
117
128
// eslint-disable-next-line @typescript-eslint/no-explicit-any
118
129
} as any ;
119
130
write ( validBedrockYaml , randomTmpDir ) ;
131
+ const expectedFilePath = path . join ( randomTmpDir , "bedrock.yaml" ) ;
132
+ expect ( writeSpy ) . toBeCalledWith (
133
+ expectedFilePath ,
134
+ `${ getVersionMessage ( ) } \n` ,
135
+ "utf8"
136
+ ) ;
137
+
120
138
expect ( ( ) => {
121
139
Bedrock ( randomTmpDir ) ;
122
140
} ) . toThrow ( ) ;
0 commit comments