File: renderer_test.go

package info (click to toggle)
golang-github-alecaivazis-survey 2.3.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 652 kB
  • sloc: makefile: 12
file content (30 lines) | stat: -rwxr-xr-x 652 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package survey

import (
	"fmt"
	"testing"

	"github.com/AlecAivazis/survey/v2/core"
)

func TestValidationError(t *testing.T) {

	err := fmt.Errorf("Football is not a valid month")

	actual, _, err := core.RunTemplate(
		ErrorTemplate,
		&ErrorTemplateData{
			Error: err,
			Icon:  defaultIcons().Error,
		},
	)
	if err != nil {
		t.Errorf("Failed to run template to format error: %s", err)
	}

	expected := fmt.Sprintf("%s Sorry, your reply was invalid: Football is not a valid month\n", defaultIcons().Error.Text)

	if actual != expected {
		t.Errorf("Formatted error was not formatted correctly. Found:\n%s\nExpected:\n%s", actual, expected)
	}
}