mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-08 01:41:42 +08:00

* remove 'test' project * dynamic template list generation - uses a single fs.Embed to contain all templates - walks and rebuilds the list of TemplateData using the cached data - pulls the `description` out of the required `template.json` file in the template directory * [v3] template handling update - move "common" template files to a _common directory - update generator to render from _common/* first - render selected template last to overwrite anything provided by _common if needed - remove duplicate files from all templates that do not change * cleanup template project directory after test * add linux to _common/Taskfile.yaml * noop: whitespace cleanup _common/Taskfile.yaml
45 lines
885 B
Go
45 lines
885 B
Go
package templates
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/wailsapp/wails/v3/internal/flags"
|
|
)
|
|
|
|
func TestInstall(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
name string
|
|
options *flags.Init
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "should install template",
|
|
options: &flags.Init{
|
|
ProjectName: "test",
|
|
TemplateName: "svelte",
|
|
Quiet: false,
|
|
},
|
|
wantErr: false,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
// Remove test directory if it exists
|
|
if _, err := os.Stat(tt.options.ProjectName); err == nil {
|
|
_ = os.RemoveAll(tt.options.ProjectName)
|
|
}
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if err := Install(tt.options); (err != nil) != tt.wantErr {
|
|
t.Errorf("Install() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
t.Cleanup(func() {
|
|
path, _ := os.Getwd()
|
|
_ = os.RemoveAll(filepath.Join(path, "..", tt.options.ProjectName))
|
|
})
|
|
}
|
|
|
|
}
|