MCPcopy
hub / github.com/livebud/bud / TestProtocol

Function TestProtocol

framework/controller/controller_test.go:2364–2669  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2362}
2363
2364func TestProtocol(t *testing.T) {
2365 is := is.New(t)
2366 ctx := context.Background()
2367 dir := t.TempDir()
2368 td := testdir.New(dir)
2369 td.NodeModules["svelte"] = versions.Svelte
2370 td.NodeModules["livebud"] = "*"
2371 td.Files["model/model.go"] = `
2372 package model
2373 type MyArticle struct {
2374 SlugID string
2375 }
2376 `
2377 td.Files["controller/controller.go"] = `
2378 package controller
2379 import "app.com/model"
2380 type Controller struct {}
2381 type MyPost struct {
2382 ID string ` + "`" + `json:"id"` + "`" + `
2383 }
2384 func (c *Controller) Index() string { return "index" }
2385 func (c *Controller) IndexErr() (string, error) { return "index_err", nil }
2386 func (c *Controller) Named() (name string) { return "named" }
2387 func (c *Controller) NamedErr() (name string, err error) { return "named_err", nil }
2388 func (c *Controller) Post() *MyPost { return &MyPost{ID:"post"} }
2389 func (c *Controller) PostErr() (*MyPost, error) { return &MyPost{ID:"post_err"}, nil }
2390 func (c *Controller) NamedPost() (post *MyPost) { return &MyPost{ID:"named_post"} }
2391 func (c *Controller) NamedPostErr() (post *MyPost, err error) { return &MyPost{ID:"named_post_err"}, nil }
2392 func (c *Controller) Article() *model.MyArticle { return &model.MyArticle{SlugID:"article"} }
2393 func (c *Controller) ArticleErr() (*model.MyArticle, error) { return &model.MyArticle{SlugID:"article_err"}, nil }
2394 func (c *Controller) NamedArticle() (article *model.MyArticle) { return &model.MyArticle{SlugID:"named_article"} }
2395 func (c *Controller) NamedArticleErr() (article *model.MyArticle, err error) { return &model.MyArticle{SlugID:"named_article_err"}, nil }
2396 `
2397 td.Files["view/index.svelte"] = `
2398 <script>
2399 export let _string = ""
2400 </script>
2401 <h1>{_string}</h1>
2402 `
2403 td.Files["view/index_err.svelte"] = `
2404 <script>
2405 export let _string = ""
2406 </script>
2407 <h1>{_string}</h1>
2408 `
2409 td.Files["view/named.svelte"] = `
2410 <script>
2411 export let name = ""
2412 </script>
2413 <h1>{name}</h1>
2414 `
2415 td.Files["view/named_err.svelte"] = `
2416 <script>
2417 export let name = ""
2418 </script>
2419 <h1>{name}</h1>
2420 `
2421 td.Files["view/post.svelte"] = `

Callers

nothing calls this directly

Calls 13

NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NoErrMethod · 0.80
GetJSONMethod · 0.80
DiffMethod · 0.80
QueryMethod · 0.80
EqualMethod · 0.80
StatusMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected