github.com/JarrahG/buffalocli@v0.0.0-20230801092127-b85bfd5d395a/internal/genny/fix/embed_test.go (about)

     1  package fix
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/gobuffalo/genny/v2/gentest"
     7  	"github.com/gobuffalo/meta"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func Test_FixEmbed_ApiProject(t *testing.T) {
    12  	r := require.New(t)
    13  
    14  	run := gentest.NewRunner()
    15  
    16  	opts := &Options{
    17  		App: meta.App{
    18  			Root:  ".",
    19  			AsAPI: true,
    20  		},
    21  	}
    22  	g := FixEmbed(opts)
    23  	run.WithRun(g)
    24  
    25  	r.NoError(run.Run())
    26  	results := run.Results()
    27  
    28  	f, err := results.Find("locales/embed.go")
    29  	r.NoError(err)
    30  	r.Contains(f.String(), "buffalo.NewFS")
    31  }
    32  
    33  func Test_FixEmbed_WebProject(t *testing.T) {
    34  	r := require.New(t)
    35  
    36  	run := gentest.NewRunner()
    37  
    38  	opts := &Options{
    39  		App: meta.App{
    40  			Root: ".",
    41  		},
    42  	}
    43  	g := FixEmbed(opts)
    44  	run.WithRun(g)
    45  
    46  	r.NoError(run.Run())
    47  	results := run.Results()
    48  
    49  	f, err := results.Find("locales/embed.go")
    50  	r.NoError(err)
    51  	r.Contains(f.String(), "buffalo.NewFS")
    52  
    53  	f, err = results.Find("public/embed.go")
    54  	r.NoError(err)
    55  	r.Contains(f.String(), "buffalo.NewFS")
    56  
    57  	f, err = results.Find("templates/embed.go")
    58  	r.NoError(err)
    59  	r.Contains(f.String(), "buffalo.NewFS")
    60  }