@@ -11,6 +11,8 @@ import (
11
11
"github.com/go-openapi/spec"
12
12
)
13
13
14
+ var coveredPaths map [string ]bool = make (map [string ]bool )
15
+
14
16
func iteratePathsAndCalculate (swagger * spec.Swagger , f []byte ) float64 {
15
17
// Convert the file content to a string
16
18
fileContent := string (f )
@@ -27,8 +29,10 @@ func iteratePathsAndCalculate(swagger *spec.Swagger, f []byte) float64 {
27
29
// Check if the file content contains the path
28
30
if strings .Contains (fileContent , path ) {
29
31
foundPathCount ++
32
+ coveredPaths [path ] = true
30
33
} else {
31
34
// fmt.Printf("Path not found in go-pinot-api.go: %s\n", path)
35
+ coveredPaths [path ] = false
32
36
}
33
37
}
34
38
@@ -68,6 +72,24 @@ func writeToCoverageFile(coverage float64) {
68
72
69
73
}
70
74
75
+ func writeCoverageMapToFile () {
76
+ filePath := filepath .Join ("." , "coverageMap.txt" )
77
+
78
+ f , err := os .Create (filePath )
79
+ if err != nil {
80
+ panic (err )
81
+ }
82
+ defer f .Close ()
83
+
84
+ for k , v := range coveredPaths {
85
+ _ , err = f .WriteString (fmt .Sprintf ("%s: %t\n " , k , v ))
86
+ if err != nil {
87
+ panic (err )
88
+ }
89
+ }
90
+
91
+ }
92
+
71
93
func main () {
72
94
filePath := filepath .Join ("." , "swagger.json" )
73
95
@@ -83,4 +105,6 @@ func main() {
83
105
84
106
writeToCoverageFile (coverage )
85
107
108
+ writeCoverageMapToFile ()
109
+
86
110
}
0 commit comments