MCPcopy Create free account
hub / github.com/GoTestTools/gotestfmt / RenderWithSettingsAndExitCode

Function RenderWithSettingsAndExitCode

renderer/renderer.go:89–151  ·  view source on GitHub ↗

RenderWithSettingsAndExitCode takes the two input channels from the parser and renders them into text output fragments as well as an exit code.

(
	prefixes <-chan string,
	downloadsChannel <-chan *parser.Downloads,
	packagesChannel <-chan *parser.Package,
	downloadsTemplate []byte,
	packagesTemplate []byte,
	settings RenderSettings,
)

Source from the content-addressed store, hash-verified

87// RenderWithSettingsAndExitCode takes the two input channels from the parser and renders them into text output
88// fragments as well as an exit code.
89func RenderWithSettingsAndExitCode(
90 prefixes <-chan string,
91 downloadsChannel <-chan *parser.Downloads,
92 packagesChannel <-chan *parser.Package,
93 downloadsTemplate []byte,
94 packagesTemplate []byte,
95 settings RenderSettings,
96) (<-chan []byte, <-chan int) {
97 result := make(chan []byte)
98 exitCodeChan := make(chan int)
99 go func() {
100 exitCode := 0
101 defer func() {
102 close(result)
103 exitCodeChan <- exitCode
104 close(exitCodeChan)
105 }()
106 for {
107 prefix, ok := <-prefixes
108 if !ok {
109 break
110 }
111 result <- []byte(fmt.Sprintf("%s\n", prefix))
112 }
113
114 for {
115 downloads, ok := <-downloadsChannel
116 if !ok {
117 break
118 }
119 if downloads.Failed {
120 exitCode = 1
121 }
122 result <- renderTemplate(
123 "downloads.gotpl",
124 downloadsTemplate,
125 Downloads{
126 downloads,
127 settings,
128 },
129 )
130 }
131
132 for {
133 pkg, ok := <-packagesChannel
134 if !ok {
135 break
136 }
137 if pkg.Result == parser.ResultFail {
138 exitCode = 1
139 }
140 result <- renderTemplate(
141 "package.gotpl",
142 packagesTemplate,
143 Package{
144 pkg,
145 settings,
146 },

Callers 1

Calls 1

renderTemplateFunction · 0.85

Tested by

no test coverage detected