Merge pull request #2003 from huiyifyj/ctx-nil-and-others
fix: check for nil and return explicit type for `UseWithCtx` method
This commit is contained in:
@@ -2,10 +2,11 @@ package system
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
|
||||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_autoCodePackage_Create(t *testing.T) {
|
func Test_autoCodePackage_Create(t *testing.T) {
|
||||||
@@ -53,9 +54,10 @@ func Test_autoCodePackage_Create(t *testing.T) {
|
|||||||
|
|
||||||
func Test_autoCodePackage_templates(t *testing.T) {
|
func Test_autoCodePackage_templates(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
entity model.SysAutoCodePackage
|
entity model.SysAutoCodePackage
|
||||||
info request.AutoCode
|
info request.AutoCode
|
||||||
|
isPackage bool
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -78,6 +80,7 @@ func Test_autoCodePackage_templates(t *testing.T) {
|
|||||||
Abbreviation: "user",
|
Abbreviation: "user",
|
||||||
HumpPackageName: "user",
|
HumpPackageName: "user",
|
||||||
},
|
},
|
||||||
|
isPackage: false,
|
||||||
},
|
},
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
@@ -85,7 +88,7 @@ func Test_autoCodePackage_templates(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
s := &autoCodePackage{}
|
s := &autoCodePackage{}
|
||||||
gotCode, gotEnter, gotCreates, err := s.templates(tt.args.ctx, tt.args.entity, tt.args.info)
|
gotCode, gotEnter, gotCreates, err := s.templates(tt.args.ctx, tt.args.entity, tt.args.info, tt.args.isPackage)
|
||||||
if (err != nil) != tt.wantErr {
|
if (err != nil) != tt.wantErr {
|
||||||
t.Errorf("templates() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("templates() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
return
|
return
|
||||||
|
@@ -5,7 +5,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||||
"github.com/mojocn/base64Captcha"
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,8 +22,10 @@ type RedisStore struct {
|
|||||||
Context context.Context
|
Context context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RedisStore) UseWithCtx(ctx context.Context) base64Captcha.Store {
|
func (rs *RedisStore) UseWithCtx(ctx context.Context) *RedisStore {
|
||||||
rs.Context = ctx
|
if ctx == nil {
|
||||||
|
rs.Context = ctx
|
||||||
|
}
|
||||||
return rs
|
return rs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,9 +51,9 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/eslint-parser": "^7.25.1",
|
"@babel/eslint-parser": "^7.25.1",
|
||||||
"@eslint/js": "^9.14.0",
|
"@eslint/js": "^8.56.0",
|
||||||
"@vitejs/plugin-legacy": "^5.4.2",
|
"@vitejs/plugin-legacy": "^6.0.0",
|
||||||
"@vitejs/plugin-vue": "^5.1.4",
|
"@vitejs/plugin-vue": "^5.0.3",
|
||||||
"@vue/cli-plugin-babel": "~5.0.8",
|
"@vue/cli-plugin-babel": "~5.0.8",
|
||||||
"@vue/cli-plugin-eslint": "~5.0.8",
|
"@vue/cli-plugin-eslint": "~5.0.8",
|
||||||
"@vue/cli-plugin-router": "~5.0.8",
|
"@vue/cli-plugin-router": "~5.0.8",
|
||||||
@@ -63,13 +63,13 @@
|
|||||||
"babel-plugin-import": "^1.13.8",
|
"babel-plugin-import": "^1.13.8",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"eslint": "^9.14.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-vue": "^9.30.0",
|
"eslint-plugin-vue": "^9.19.2",
|
||||||
"sass": "^1.78.0",
|
"sass": "^1.78.0",
|
||||||
"terser": "^5.31.6",
|
"terser": "^5.31.6",
|
||||||
"vite": "^5.4.3",
|
"vite": "^6.2.3",
|
||||||
"vite-plugin-banner": "^0.8.0",
|
"vite-plugin-banner": "^0.8.0",
|
||||||
"vite-plugin-importer": "^0.2.5",
|
"vite-plugin-importer": "^0.2.5",
|
||||||
"vite-plugin-vue-devtools": "^7.4.4"
|
"vite-plugin-vue-devtools": "^7.0.16"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
color:
|
color:
|
||||||
row.defaultRouter === data.name ? '#E6A23C' : '#85ce61'
|
row.defaultRouter === data.name ? '#E6A23C' : '#85ce61'
|
||||||
}"
|
}"
|
||||||
@click="() => setDefault(data)"
|
@click.stop="() => setDefault(data)"
|
||||||
>
|
>
|
||||||
{{ row.defaultRouter === data.name ? '首页' : '设为首页' }}
|
{{ row.defaultRouter === data.name ? '首页' : '设为首页' }}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
Reference in New Issue
Block a user