5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 00:10:47 +08:00

v3 parser: fix model tests when no structs returned

This commit is contained in:
Adam Tenderholt 2023-03-13 06:07:04 -07:00
parent be1624ca9f
commit 1c9a52463b
2 changed files with 9 additions and 5 deletions

View File

@ -43,6 +43,10 @@ func pkgAlias(fullPkg string) string {
}
func GenerateModels(models map[packagePath]map[structName]*StructDef) (string, error) {
if models == nil {
return "", nil
}
var buffer bytes.Buffer
buffer.WriteString(modelsHeader)

View File

@ -15,7 +15,7 @@ func TestGenerateModels(t *testing.T) {
}{
{
"testdata/function_single",
getFile("testdata/function_single/models.ts"),
"",
},
{
"testdata/function_from_imported_package",
@ -23,11 +23,11 @@ func TestGenerateModels(t *testing.T) {
},
{
"testdata/variable_single",
getFile("testdata/variable_single/models.ts"),
"",
},
{
"testdata/variable_single_from_function",
getFile("testdata/variable_single_from_function/models.ts"),
"",
},
{
"testdata/variable_single_from_other_function",
@ -39,7 +39,7 @@ func TestGenerateModels(t *testing.T) {
},
{
"testdata/struct_literal_multiple",
getFile("testdata/struct_literal_multiple/models.ts"),
"",
},
{
"testdata/struct_literal_multiple_other",
@ -47,7 +47,7 @@ func TestGenerateModels(t *testing.T) {
},
{
"testdata/struct_literal_multiple_files",
getFile("testdata/struct_literal_multiple_files/models.ts"),
"",
},
}
for _, tt := range tests {