-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ded002
commit ef2535d
Showing
8 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package controller | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestGenTemplate(t *testing.T) { | ||
modelName := "TestModel" | ||
template := GenTemplate(modelName) | ||
if template == "" { | ||
t.Error("Expected non-empty template") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package curd_orm | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestBootMS(t *testing.T) { | ||
db := BootMS() | ||
if db == nil { | ||
t.Error("Expected a valid database instance") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
package model | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func Gen(modelName string) error { | ||
template := GenTemplate(modelName) | ||
err := CopyToModelPath(modelName, template) | ||
return err | ||
if err != nil { | ||
return fmt.Errorf("failed to copy to model path: %w", err) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package model | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestGenTemplate(t *testing.T) { | ||
modelName := "TestModel" | ||
expectedTemplate := ` | ||
package models | ||
import ( | ||
"github.com/goravel/framework/database/orm" | ||
) | ||
type TestModel struct { | ||
orm.Model | ||
orm.SoftDeletes | ||
} | ||
` | ||
// Generate the template | ||
template := GenTemplate(modelName) | ||
|
||
// Check if the generated template matches the expected template | ||
if template != expectedTemplate { | ||
t.Errorf("Expected template:\n%s\nGot:\n%s", expectedTemplate, template) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package facades | ||
|
||
import ( | ||
crud "goravel/packages/goravel-crud" | ||
"log" | ||
|
||
"goravel/packages/goravel-crud/contracts" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
go tool cover -func=coverage.out | grep total | awk '{print $3}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package model | ||
|
||
import ( | ||
"github.com/goravel/framework/database/orm" | ||
) | ||
|
||
type TestModel struct { | ||
orm.Model | ||
Username string `gorm:"column:username" form:"username" json:"username"` | ||
Password string `gorm:"column:password" form:"password" json:"password"` | ||
orm.SoftDeletes | ||
} |