Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix failed test #561

Merged
merged 3 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions internal/log/glg/glg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestSetLevelMode(t *testing.T) {
return errors.New("error level is wrong")
}

if g.GetCurrentMode(glg.FAIL) != glg.STD {
if g.GetCurrentMode(glg.FATAL) != glg.STD {
return errors.New("fatal level is wrong")
}

Expand Down Expand Up @@ -147,7 +147,7 @@ func TestSetLevelMode(t *testing.T) {
return errors.New("error level is wrong")
}

if g.GetCurrentMode(glg.FAIL) != glg.STD {
if g.GetCurrentMode(glg.FATAL) != glg.STD {
return errors.New("fatal level is wrong")
}

Expand Down Expand Up @@ -182,7 +182,7 @@ func TestSetLevelMode(t *testing.T) {
return errors.New("error level is wrong")
}

if g.GetCurrentMode(glg.FAIL) != glg.STD {
if g.GetCurrentMode(glg.FATAL) != glg.STD {
return errors.New("fatal level is wrong")
}

Expand Down Expand Up @@ -217,7 +217,7 @@ func TestSetLevelMode(t *testing.T) {
return errors.New("error level is wrong")
}

if g.GetCurrentMode(glg.FAIL) != glg.STD {
if g.GetCurrentMode(glg.FATAL) != glg.STD {
return errors.New("fatal level is wrong")
}

Expand Down Expand Up @@ -252,7 +252,7 @@ func TestSetLevelMode(t *testing.T) {
return errors.New("error level is wrong")
}

if g.GetCurrentMode(glg.FAIL) != glg.STD {
if g.GetCurrentMode(glg.FATAL) != glg.STD {
return errors.New("fatal level is wrong")
}

Expand Down Expand Up @@ -287,7 +287,7 @@ func TestSetLevelMode(t *testing.T) {
return errors.New("error level is wrong")
}

if g.GetCurrentMode(glg.FAIL) != glg.NONE {
if g.GetCurrentMode(glg.FATAL) != glg.NONE {
return errors.New("fatal level is wrong")
}

Expand All @@ -301,7 +301,6 @@ func TestSetLevelMode(t *testing.T) {
l := (&logger{
glg: tt.field.glg,
}).setLevelMode(tt.args.lv)

if err := tt.checkFunc(l); err != nil {
t.Error(err)
}
Expand Down
120 changes: 102 additions & 18 deletions internal/servers/server/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ func TestWithGRPCMaxReceiveMessageSize(t *testing.T) {

tests := []test{
{
name: "set success",
name: "set success when size is mode than 0",
size: 1024,
checkFunc: func(opt Option) error {
got := new(server)
Expand All @@ -1223,6 +1223,20 @@ func TestWithGRPCMaxReceiveMessageSize(t *testing.T) {
},
},

{
name: "set success when size is -1",
size: -1,
checkFunc: func(opt Option) error {
got := new(server)
opt(got)

if len(got.grpc.opts) != 1 {
return errors.New("invalid param was set")
}
return nil
},
},

{
name: "not set when size is 0",
checkFunc: func(opt Option) error {
Expand All @@ -1241,8 +1255,8 @@ func TestWithGRPCMaxReceiveMessageSize(t *testing.T) {
},

{
name: "not set when size is less than 0",
size: -1,
name: "not set when size is less than -1",
size: -2,
checkFunc: func(opt Option) error {
sopts := []grpc.ServerOption{
grpc.ConnectionTimeout(100 * time.Second),
Expand Down Expand Up @@ -1278,7 +1292,7 @@ func TestWithGRPCMaxSendMessageSize(t *testing.T) {

tests := []test{
{
name: "set success",
name: "set success when size is more than 0",
size: 1024,
checkFunc: func(opt Option) error {
got := new(server)
Expand All @@ -1291,6 +1305,20 @@ func TestWithGRPCMaxSendMessageSize(t *testing.T) {
},
},

{
name: "set success when size is -1",
size: -1,
checkFunc: func(opt Option) error {
got := new(server)
opt(got)

if len(got.grpc.opts) != 1 {
return errors.New("invalid param was set")
}
return nil
},
},

{
name: "not set when size is 0",
checkFunc: func(opt Option) error {
Expand All @@ -1309,8 +1337,8 @@ func TestWithGRPCMaxSendMessageSize(t *testing.T) {
},

{
name: "not set when size is less than 0",
size: -1,
name: "not set when size is less than -1",
size: -2,
checkFunc: func(opt Option) error {
sopts := []grpc.ServerOption{
grpc.ConnectionTimeout(100 * time.Second),
Expand Down Expand Up @@ -1346,7 +1374,7 @@ func TestWithGRPCInitialWindowSize(t *testing.T) {

tests := []test{
{
name: "set success",
name: "set success when size is more than 0",
size: 1024,
checkFunc: func(opt Option) error {
got := new(server)
Expand All @@ -1359,6 +1387,20 @@ func TestWithGRPCInitialWindowSize(t *testing.T) {
},
},

{
name: "set success when size is -1",
size: -1,
checkFunc: func(opt Option) error {
got := new(server)
opt(got)

if len(got.grpc.opts) != 1 {
return errors.New("invalid param was set")
}
return nil
},
},

{
name: "not set when size is 0",
checkFunc: func(opt Option) error {
Expand All @@ -1377,8 +1419,8 @@ func TestWithGRPCInitialWindowSize(t *testing.T) {
},

{
name: "not set when size is less than 0",
size: -1,
name: "not set when size is less than -1",
size: -2,
checkFunc: func(opt Option) error {
sopts := []grpc.ServerOption{
grpc.ConnectionTimeout(100 * time.Second),
Expand Down Expand Up @@ -1414,7 +1456,7 @@ func TestWithGRPCInitialConnWindowSize(t *testing.T) {

tests := []test{
{
name: "set success",
name: "set success when size is more than 0",
size: 1024,
checkFunc: func(opt Option) error {
got := new(server)
Expand All @@ -1427,6 +1469,20 @@ func TestWithGRPCInitialConnWindowSize(t *testing.T) {
},
},

{
name: "set success when size is -1",
size: -1,
checkFunc: func(opt Option) error {
got := new(server)
opt(got)

if len(got.grpc.opts) != 1 {
return errors.New("invalid param was set")
}
return nil
},
},

{
name: "not set when size is 0",
checkFunc: func(opt Option) error {
Expand All @@ -1445,8 +1501,8 @@ func TestWithGRPCInitialConnWindowSize(t *testing.T) {
},

{
name: "not set when size is less than 0",
size: -1,
name: "not set when size is less than -1",
size: -2,
checkFunc: func(opt Option) error {
sopts := []grpc.ServerOption{
grpc.ConnectionTimeout(100 * time.Second),
Expand Down Expand Up @@ -1822,7 +1878,7 @@ func TestWithGRPCWriteBufferSize(t *testing.T) {

tests := []test{
{
name: "set success",
name: "set success when size is more than 0",
size: 1024,
checkFunc: func(opt Option) error {
got := new(server)
Expand All @@ -1835,6 +1891,20 @@ func TestWithGRPCWriteBufferSize(t *testing.T) {
},
},

{
name: "set success when size is -1",
size: -1,
checkFunc: func(opt Option) error {
got := new(server)
opt(got)

if len(got.grpc.opts) != 1 {
return errors.New("invalid param was set")
}
return nil
},
},

{
name: "not set when size is 0",
checkFunc: func(opt Option) error {
Expand All @@ -1853,8 +1923,8 @@ func TestWithGRPCWriteBufferSize(t *testing.T) {
},

{
name: "not set when size is less than 0",
size: -1,
name: "not set when size is less than -1",
size: -2,
checkFunc: func(opt Option) error {
gopts := []grpc.ServerOption{
grpc.ConnectionTimeout(10 * time.Second),
Expand Down Expand Up @@ -1890,7 +1960,7 @@ func TestWithGRPCReadBufferSize(t *testing.T) {

tests := []test{
{
name: "set success",
name: "set success when size is more than 0",
size: 1024,
checkFunc: func(opt Option) error {
got := new(server)
Expand All @@ -1903,6 +1973,20 @@ func TestWithGRPCReadBufferSize(t *testing.T) {
},
},

{
name: "set success when size is -1",
size: -1,
checkFunc: func(opt Option) error {
got := new(server)
opt(got)

if len(got.grpc.opts) != 1 {
return errors.New("invalid param was set")
}
return nil
},
},

{
name: "not set when size is 0",
checkFunc: func(opt Option) error {
Expand All @@ -1921,8 +2005,8 @@ func TestWithGRPCReadBufferSize(t *testing.T) {
},

{
name: "not set when size is less than 0",
size: -1,
name: "not set when size is less than -1",
size: -2,
checkFunc: func(opt Option) error {
gopts := []grpc.ServerOption{
grpc.ConnectionTimeout(10 * time.Second),
Expand Down