MCPcopy Create free account
hub / github.com/AdRoll/baker / TestGenerateHelp

Function TestGenerateHelp

help_config_test.go:96–150  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

94}
95
96func TestGenerateHelp(t *testing.T) {
97 tests := []struct {
98 name string
99 desc interface{}
100 wantErr bool
101 }{
102 {
103 name: "nil",
104 desc: nil,
105 wantErr: true,
106 },
107 {
108 name: "unsupported type",
109 desc: 23,
110 wantErr: true,
111 },
112 {
113 name: "supported configuration",
114 desc: InputDesc{Name: "name", Config: &dummyConfig{
115 IntField: 1,
116 Int64Field: 2,
117 DurationField: 3,
118 StringField: "5",
119 BoolField: false,
120 SliceOfStringsField: []string{"foo", "bar"},
121 SliceOfIntsField: []int{0, 1, 2, 3, 4, 5},
122 MapOfStringsToStrings: map[string]string{"foo": "bar", "bar": "foo"},
123 MapOfStringsToInt: map[string]int{"foo": 12, "bar": 5},
124 Bytes: SizeBytes(120_000_000),
125 }},
126 },
127 }
128 for _, tt := range tests {
129 t.Run(tt.name+"/text", func(t *testing.T) {
130 w := &bytes.Buffer{}
131 if err := GenerateTextHelp(w, tt.desc); (err != nil) != tt.wantErr {
132 t.Errorf("GenerateTextHelp() error = %v, wantErr %v", err, tt.wantErr)
133 return
134 }
135 if !tt.wantErr && w.String() == "" {
136 t.Errorf(`GenerateTextHelp() = "", shouldn't be empty`)
137 }
138 })
139 t.Run(tt.name+"/markdown", func(t *testing.T) {
140 w := &bytes.Buffer{}
141 if err := GenerateMarkdownHelp(w, tt.desc); (err != nil) != tt.wantErr {
142 t.Errorf("GenerateMarkdownHelp() error = %v, wantErr %v", err, tt.wantErr)
143 return
144 }
145 if !tt.wantErr && w.String() == "" {
146 t.Errorf(`GenerateMarkdownHelp() = "", shouldn't be empty`)
147 }
148 })
149 }
150}
151
152func Test_newInputDoc(t *testing.T) {
153 const (

Callers

nothing calls this directly

Calls 5

SizeBytesTypeAlias · 0.85
GenerateTextHelpFunction · 0.85
GenerateMarkdownHelpFunction · 0.85
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected