Fix tests

pull/2561/head
Shelikhoo 2020-06-08 16:16:50 +08:00
parent 09b81b78c3
commit 00103d1f73
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
3 changed files with 8 additions and 5 deletions

View File

@ -54,7 +54,7 @@ func TestGetStats(t *testing.T) {
} }
} else { } else {
common.Must(err) common.Must(err)
if r := cmp.Diff(resp.Stat, &Stat{Name: tc.name, Value: tc.value}); r != "" { if r := cmp.Diff(resp.Stat, &Stat{Name: tc.name, Value: tc.value}, cmpopts.IgnoreUnexported(Stat{})); r != "" {
t.Error(r) t.Error(r)
} }
} }
@ -85,7 +85,8 @@ func TestQueryStats(t *testing.T) {
if r := cmp.Diff(resp.Stat, []*Stat{ if r := cmp.Diff(resp.Stat, []*Stat{
{Name: "test_counter_2", Value: 2}, {Name: "test_counter_2", Value: 2},
{Name: "test_counter_3", Value: 3}, {Name: "test_counter_3", Value: 3},
}, cmpopts.SortSlices(func(s1, s2 *Stat) bool { return s1.Name < s2.Name })); r != "" { }, cmpopts.SortSlices(func(s1, s2 *Stat) bool { return s1.Name < s2.Name }),
cmpopts.IgnoreUnexported(Stat{})); r != "" {
t.Error(r) t.Error(r)
} }
} }

View File

@ -2,6 +2,7 @@ package conf_test
import ( import (
"encoding/json" "encoding/json"
"github.com/google/go-cmp/cmp/cmpopts"
"os" "os"
"testing" "testing"
@ -216,7 +217,7 @@ func TestUserParsing(t *testing.T) {
if r := cmp.Diff(nUser, &protocol.User{ if r := cmp.Diff(nUser, &protocol.User{
Level: 1, Level: 1,
Email: "love@v2ray.com", Email: "love@v2ray.com",
}); r != "" { }, cmpopts.IgnoreUnexported(protocol.User{})); r != "" {
t.Error(r) t.Error(r)
} }
} }

View File

@ -3,6 +3,7 @@ package scenarios
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/google/go-cmp/cmp/cmpopts"
"io" "io"
"strings" "strings"
"testing" "testing"
@ -471,7 +472,7 @@ func TestCommanderStats(t *testing.T) {
if r := cmp.Diff(sresp.Stat, &statscmd.Stat{ if r := cmp.Diff(sresp.Stat, &statscmd.Stat{
Name: name, Name: name,
Value: 10240 * 1024, Value: 10240 * 1024,
}); r != "" { }, cmpopts.IgnoreUnexported(statscmd.Stat{})); r != "" {
t.Error(r) t.Error(r)
} }
@ -482,7 +483,7 @@ func TestCommanderStats(t *testing.T) {
if r := cmp.Diff(sresp.Stat, &statscmd.Stat{ if r := cmp.Diff(sresp.Stat, &statscmd.Stat{
Name: name, Name: name,
Value: 0, Value: 0,
}); r != "" { }, cmpopts.IgnoreUnexported(statscmd.Stat{})); r != "" {
t.Error(r) t.Error(r)
} }