X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/625b0580010c7fbf183c53e388ceba8356df76f4..154adcc6b47b3cb278f655a9580311e14de7444d:/hotline/server_blackbox_test.go diff --git a/hotline/server_blackbox_test.go b/hotline/server_blackbox_test.go index b8990ad..64d56ab 100644 --- a/hotline/server_blackbox_test.go +++ b/hotline/server_blackbox_test.go @@ -4,11 +4,12 @@ import ( "bytes" "context" "fmt" + "github.com/davecgh/go-spew/spew" + "github.com/stretchr/testify/assert" "go.uber.org/zap" "go.uber.org/zap/zapcore" "net" "os" - "reflect" "testing" ) @@ -22,7 +23,7 @@ type testCase struct { } func (tt *testCase) Setup(srv *Server) error { - if err := srv.NewUser(tt.account.Login, tt.account.Name, NegatedUserString([]byte(tt.account.Password)), *tt.account.Access); err != nil { + if err := srv.NewUser(tt.account.Login, tt.account.Name, string(negateString([]byte(tt.account.Password))), *tt.account.Access); err != nil { return err } @@ -122,7 +123,6 @@ func TestHandshake(t *testing.T) { // } //} - func TestNewUser(t *testing.T) { srv, _, _ := StartTestServer() @@ -310,24 +310,21 @@ func TestNewUser(t *testing.T) { } } +func tranAssertEqual(t *testing.T, tran1, tran2 []Transaction) bool { + var newT1 []Transaction + var newT2 []Transaction + for _, trans := range tran1{ + trans.ID = []byte{0,0,0,0} + newT1 = append(newT1, trans) + } + for _, trans := range tran2{ + trans.ID = []byte{0,0,0,0} + newT2 = append(newT2, trans) -// equal is a utility function used only in tests that determines if transactions are equal enough -func (t Transaction) equal(otherT Transaction) bool { - t.ID = []byte{0, 0, 0, 0} - otherT.ID = []byte{0, 0, 0, 0} - - t.TotalSize = []byte{0, 0, 0, 0} - otherT.TotalSize = []byte{0, 0, 0, 0} - - t.DataSize = []byte{0, 0, 0, 0} - otherT.DataSize = []byte{0, 0, 0, 0} - - t.ParamCount = []byte{0, 0} - otherT.ParamCount = []byte{0, 0} + } - //spew.Dump(t) - //spew.Dump(otherT) + spew.Dump(newT1, newT2) - return reflect.DeepEqual(t, otherT) -} + return assert.Equal(t, newT1, newT2) +} \ No newline at end of file