✨ init project
This commit is contained in:
105
service/system/auto_code_package_test.go
Normal file
105
service/system/auto_code_package_test.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
model "git.echol.cn/loser/lckt/model/system"
|
||||
"git.echol.cn/loser/lckt/model/system/request"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_autoCodePackage_Create(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
info *request.SysAutoCodePackageCreate
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "测试 package",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
info: &request.SysAutoCodePackageCreate{
|
||||
Template: "package",
|
||||
PackageName: "gva",
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "测试 plugin",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
info: &request.SysAutoCodePackageCreate{
|
||||
Template: "plugin",
|
||||
PackageName: "gva",
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
a := &autoCodePackage{}
|
||||
if err := a.Create(tt.args.ctx, tt.args.info); (err != nil) != tt.wantErr {
|
||||
t.Errorf("Create() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_autoCodePackage_templates(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
entity model.SysAutoCodePackage
|
||||
info request.AutoCode
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantCode map[string]string
|
||||
wantEnter map[string]map[string]string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "测试1",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
entity: model.SysAutoCodePackage{
|
||||
Desc: "描述",
|
||||
Label: "展示名",
|
||||
Template: "plugin",
|
||||
PackageName: "preview",
|
||||
},
|
||||
info: request.AutoCode{
|
||||
Abbreviation: "user",
|
||||
HumpPackageName: "user",
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
s := &autoCodePackage{}
|
||||
gotCode, gotEnter, gotCreates, err := s.templates(tt.args.ctx, tt.args.entity, tt.args.info)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("templates() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
for key, value := range gotCode {
|
||||
t.Logf("\n")
|
||||
t.Logf(key)
|
||||
t.Logf(value)
|
||||
t.Logf("\n")
|
||||
}
|
||||
t.Log(gotCreates)
|
||||
if !reflect.DeepEqual(gotEnter, tt.wantEnter) {
|
||||
t.Errorf("templates() gotEnter = %v, want %v", gotEnter, tt.wantEnter)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user