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

Function TestPkgGenerator

framework/generator/generator_test.go:360–389  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

358}
359
360func TestPkgGenerator(t *testing.T) {
361 is := is.New(t)
362 ctx := context.Background()
363 dir := t.TempDir()
364 td := testdir.New(dir)
365 td.Files["generator/tailwind/tailwind.go"] = `
366 package tailwind
367 import (
368 "github.com/livebud/bud/package/genfs"
369 )
370 type Generator struct {}
371 func (g *Generator) GeneratePkg(fsys genfs.FS, dir *genfs.Dir) error {
372 dir.GenerateFile("tailwind.css", func(fsys genfs.FS, file *genfs.File) error {
373 file.Data = []byte("/** tailwind **/")
374 return nil
375 })
376 return nil
377 }
378 `
379 is.NoErr(td.Write(ctx))
380 cli := testcli.New(dir)
381 res, err := cli.Run(ctx, "build", "--embed=false")
382 is.NoErr(err)
383 is.Equal(res.Stderr(), "")
384 is.Equal(res.Stdout(), "")
385 is.NoErr(td.Exists("bud/pkg/tailwind/tailwind.css"))
386 data, err := os.ReadFile(td.Path("bud/pkg/tailwind/tailwind.css"))
387 is.NoErr(err)
388 is.Equal(string(data), "/** tailwind **/")
389}
390
391func TestCmdGenerator(t *testing.T) {
392 is := is.New(t)

Callers

nothing calls this directly

Calls 11

NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NoErrMethod · 0.80
EqualMethod · 0.80
ExistsMethod · 0.80
RunMethod · 0.65
WriteMethod · 0.45
StderrMethod · 0.45
StdoutMethod · 0.45
PathMethod · 0.45

Tested by

no test coverage detected