optimize unit test (#999)

master
anqiansong 3 years ago committed by GitHub
parent 6476da4a18
commit 84d2b64e7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,6 +8,7 @@ import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/tal-tech/go-zero/core/logx" "github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/stringx" "github.com/tal-tech/go-zero/core/stringx"
conf "github.com/tal-tech/go-zero/tools/goctl/config" conf "github.com/tal-tech/go-zero/tools/goctl/config"
@ -45,7 +46,7 @@ func TestRpcGenerate(t *testing.T) {
// case go path // case go path
t.Run("GOPATH", func(t *testing.T) { t.Run("GOPATH", func(t *testing.T) {
err = g.Generate("./test.proto", projectDir, []string{common, src}, "Mbase/common.proto=./base") err = g.Generate("./test.proto", projectDir, []string{common}, "Mbase/common.proto=./base")
assert.Nil(t, err) assert.Nil(t, err)
_, err = execx.Run("go test "+projectName, projectDir) _, err = execx.Run("go test "+projectName, projectDir)
if err != nil { if err != nil {
@ -66,7 +67,7 @@ func TestRpcGenerate(t *testing.T) {
} }
projectDir = filepath.Join(workDir, projectName) projectDir = filepath.Join(workDir, projectName)
err = g.Generate("./test.proto", projectDir, []string{common, src}, "Mbase/common.proto=./base") err = g.Generate("./test.proto", projectDir, []string{common}, "Mbase/common.proto=./base")
assert.Nil(t, err) assert.Nil(t, err)
_, err = execx.Run("go test "+projectName, projectDir) _, err = execx.Run("go test "+projectName, projectDir)
if err != nil { if err != nil {

@ -4,14 +4,11 @@ syntax = "proto3";
package test; package test;
import "base/common.proto"; import "base/common.proto";
import "google/protobuf/any.proto";
option go_package = "github.com/test"; option go_package = "github.com/test";
message Req { message Req {
string in = 1; string in = 1;
common.User user = 2; common.User user = 2;
google.protobuf.Any object = 4;
} }
message Reply { message Reply {

@ -121,8 +121,13 @@ func ReadLink(name string) (string, error) {
return "", err return "", err
} }
if name == "/" { if _, err := os.Lstat(name); err != nil {
return "/", nil return name, nil
}
// uncheck condition: ignore file path /var, maybe be temporary file path
if name == "/" || name == "/var" {
return name, nil
} }
isLink, err := isLink(name) isLink, err := isLink(name)

Loading…
Cancel
Save