Skip to content

Commit 0288584

Browse files
authored
kubetestgen: improve errors handling
- don't proceed when a file creation has been failed - handle a possible error from WriteString()
1 parent e7eed1a commit 0288584

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/conformance/kubetestgen/kubetestgen.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ func printYAML(fileName string, areaO Area) {
131131
f, err := os.Create(fileName + ".yaml")
132132
if err != nil {
133133
fmt.Printf("ERROR: %s\n", err.Error())
134+
os.Exit(1)
134135
}
135136
defer f.Close()
136137
y, err := yaml.Marshal(areaO)
@@ -139,7 +140,11 @@ func printYAML(fileName string, areaO Area) {
139140
os.Exit(1)
140141
}
141142

142-
f.WriteString(string(y))
143+
_, err = f.WriteString(string(y))
144+
if err != nil {
145+
fmt.Printf("ERROR: %s\n", err.Error())
146+
os.Exit(1)
147+
}
143148
}
144149

145150
func countFields(suites []Suite) {

0 commit comments

Comments
 (0)