MCPcopy Create free account
hub / github.com/anchordotdev/cli / recordGolden

Method recordGolden

ui/driver.go:211–238  ·  view source on GitHub ↗
(out string)

Source from the content-addressed store, hash-verified

209}
210
211func (d *Driver) recordGolden(out string) {
212 d.goldenMutex.Lock()
213 defer d.goldenMutex.Unlock()
214
215 if out == d.lastView {
216 return
217 }
218
219 var section string
220 if mdl, ok := d.active.(interface{ Section() string }); ok {
221 section = mdl.Section()
222 } else if kind := reflect.TypeOf(d.active).Kind(); kind == reflect.Interface || kind == reflect.Pointer {
223 section = reflect.TypeOf(d.active).Elem().Name()
224 } else {
225 section = reflect.TypeOf(d.active).Name()
226 }
227
228 separator := fmt.Sprintf("─── %s ", section)
229 if separatorRuneCount := utf8.RuneCountInString(separator); separatorRuneCount < 80 {
230 separator = separator + strings.Repeat("─", 80-utf8.RuneCountInString(separator))
231 } else {
232 runes := []rune(separator)
233 separator = string(runes[:79]) + "…"
234 }
235
236 d.lastView = out
237 d.golden += strings.Join([]string{separator, out}, "\n")
238}
239
240var (
241 quitPtr = reflect.ValueOf(tea.Quit).Pointer()

Callers 1

ViewMethod · 0.95

Calls 2

SectionMethod · 0.80
NameMethod · 0.80

Tested by

no test coverage detected