| 209 | } |
| 210 | |
| 211 | func (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 | |
| 240 | var ( |
| 241 | quitPtr = reflect.ValueOf(tea.Quit).Pointer() |