-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* reactor rpc generation * update flag * update command * update command * update unit test * delete test file * optimize code * update doc * update gen pb * rename target dir * update mysql data type convert rule * add done flag * optimize req/reply parameter * optimize req/reply parameter * remove waste code * remove duplicate parameter * format code * format code * optimize naming * reactor rpcv2 to rpc * remove new line * format code * rename underline to snake * reactor getParentPackage * remove debug log * reactor background
- Loading branch information
Keson
authored
Nov 5, 2020
1 parent
c9ec22d
commit e76f44a
Showing
95 changed files
with
2,698 additions
and
3,291 deletions.
There are no files selected for viewing
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
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
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
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
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
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,34 +1,64 @@ | ||
package gen | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/tal-tech/go-zero/core/logx" | ||
) | ||
|
||
var ( | ||
source = "CREATE TABLE `test_user_info` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `nanosecond` bigint NOT NULL DEFAULT '0',\n `data` varchar(255) DEFAULT '',\n `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,\n `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`),\n UNIQUE KEY `nanosecond_unique` (`nanosecond`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;" | ||
source = "CREATE TABLE `test_user_info` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `nanosecond` bigint NOT NULL DEFAULT '0',\n `data` varchar(255) DEFAULT '',\n `content` json DEFAULT NULL,\n `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,\n `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`),\n UNIQUE KEY `nanosecond_unique` (`nanosecond`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;" | ||
) | ||
|
||
func TestCacheModel(t *testing.T) { | ||
logx.Disable() | ||
_ = Clean() | ||
g := NewDefaultGenerator(source, "./testmodel/cache", NamingLower) | ||
dir, _ := filepath.Abs("./testmodel") | ||
cacheDir := filepath.Join(dir, "cache") | ||
noCacheDir := filepath.Join(dir, "nocache") | ||
defer func() { | ||
_ = os.RemoveAll(dir) | ||
}() | ||
g := NewDefaultGenerator(source, cacheDir, NamingLower) | ||
err := g.Start(true) | ||
assert.Nil(t, err) | ||
g = NewDefaultGenerator(source, "./testmodel/nocache", NamingLower) | ||
assert.True(t, func() bool { | ||
_, err := os.Stat(filepath.Join(cacheDir, "testuserinfomodel.go")) | ||
return err == nil | ||
}()) | ||
g = NewDefaultGenerator(source, noCacheDir, NamingLower) | ||
err = g.Start(false) | ||
assert.Nil(t, err) | ||
assert.True(t, func() bool { | ||
_, err := os.Stat(filepath.Join(noCacheDir, "testuserinfomodel.go")) | ||
return err == nil | ||
}()) | ||
} | ||
|
||
func TestNamingModel(t *testing.T) { | ||
logx.Disable() | ||
_ = Clean() | ||
g := NewDefaultGenerator(source, "./testmodel/camel", NamingCamel) | ||
dir, _ := filepath.Abs("./testmodel") | ||
camelDir := filepath.Join(dir, "camel") | ||
snakeDir := filepath.Join(dir, "snake") | ||
defer func() { | ||
_ = os.RemoveAll(dir) | ||
}() | ||
g := NewDefaultGenerator(source, camelDir, NamingCamel) | ||
err := g.Start(true) | ||
assert.Nil(t, err) | ||
g = NewDefaultGenerator(source, "./testmodel/snake", NamingUnderline) | ||
assert.True(t, func() bool { | ||
_, err := os.Stat(filepath.Join(camelDir, "TestUserInfoModel.go")) | ||
return err == nil | ||
}()) | ||
g = NewDefaultGenerator(source, snakeDir, NamingSnake) | ||
err = g.Start(true) | ||
assert.Nil(t, err) | ||
assert.True(t, func() bool { | ||
_, err := os.Stat(filepath.Join(snakeDir, "test_user_info_model.go")) | ||
return err == nil | ||
}()) | ||
} |
125 changes: 0 additions & 125 deletions
125
tools/goctl/model/sql/gen/testmodel/cache/testuserinfomodel.go
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.