2023-04-06 16:21:26 +02:00
|
|
|
package resource
|
|
|
|
|
|
|
|
import (
|
2023-04-08 16:27:52 +02:00
|
|
|
"context"
|
|
|
|
"fmt"
|
2023-04-06 16:21:26 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-04-08 16:27:52 +02:00
|
|
|
type TestSizeResource struct {
|
|
|
|
*MenuResource
|
|
|
|
}
|
|
|
|
|
2023-04-09 00:35:13 +02:00
|
|
|
func getTemplate(sym string) (string, error) {
|
2023-04-08 16:27:52 +02:00
|
|
|
var tpl string
|
|
|
|
switch sym {
|
|
|
|
case "small":
|
|
|
|
tpl = "one {{.foo}} two {{.bar}} three {{.baz}}"
|
|
|
|
case "toobig":
|
|
|
|
tpl = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus in mattis lorem. Aliquam erat volutpat. Ut vitae metus."
|
|
|
|
case "pages":
|
|
|
|
tpl = "one {{.foo}} two {{.bar}} three {{.baz}}\n{{.xyzzy}}"
|
|
|
|
}
|
|
|
|
return tpl, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func funcFor(sym string) (EntryFunc, error) {
|
|
|
|
switch sym {
|
|
|
|
case "foo":
|
2023-04-10 06:30:57 +02:00
|
|
|
return get, nil
|
2023-04-08 16:27:52 +02:00
|
|
|
case "bar":
|
2023-04-10 06:30:57 +02:00
|
|
|
return get, nil
|
2023-04-08 16:27:52 +02:00
|
|
|
case "baz":
|
2023-04-10 06:30:57 +02:00
|
|
|
return get, nil
|
2023-04-08 16:27:52 +02:00
|
|
|
case "xyzzy":
|
|
|
|
return getXyzzy, nil
|
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("unknown func: %s", sym)
|
|
|
|
}
|
|
|
|
|
2023-04-10 06:30:57 +02:00
|
|
|
func get(sym string, ctx context.Context) (string, error) {
|
|
|
|
switch sym {
|
|
|
|
case "foo":
|
|
|
|
return "inky", nil
|
|
|
|
case "bar":
|
|
|
|
return "pinky", nil
|
|
|
|
case "baz":
|
|
|
|
return "blinky", nil
|
|
|
|
}
|
|
|
|
return "", fmt.Errorf("unknown sym: %s", sym)
|
2023-04-08 16:27:52 +02:00
|
|
|
}
|
|
|
|
|
2023-04-10 06:30:57 +02:00
|
|
|
func getXyzzy(sym string, ctx context.Context) (string, error) {
|
2023-04-08 16:27:52 +02:00
|
|
|
return "inky pinky\nblinky clyde sue\ntinkywinky dipsy\nlala poo\none two three four five six seven\neight nine ten\neleven twelve", nil
|
2023-04-06 16:21:26 +02:00
|
|
|
}
|