Merge pull request 'Fix login test . test for package content too' (#3) from fix_login_test into master
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: http://git.tfm.ro/mihaim/elbot/pulls/3
This commit is contained in:
Mihai Moldovanu 2022-03-26 22:51:59 +00:00
commit 89b684ec90
2 changed files with 12 additions and 2 deletions

5
go.mod
View File

@ -2,4 +2,7 @@ module tfm.ro/elbot
go 1.16 go 1.16
require github.com/spf13/viper v1.8.1 // indirect require (
github.com/magiconair/properties v1.8.5 // indirect
github.com/spf13/viper v1.8.1 // indirect
)

View File

@ -3,6 +3,8 @@ package main
import ( import (
"net" "net"
"testing" "testing"
"github.com/magiconair/properties/assert"
) )
// Test scafolding // Test scafolding
@ -33,11 +35,16 @@ func TestSendLogin(t *testing.T) {
sendLogin(client, tt.name, tt.pass) sendLogin(client, tt.name, tt.pass)
}() }()
reply := make([]byte, 4096) reply := make([]byte, tt.resultLenght)
length, _ := server.Read(reply) length, _ := server.Read(reply)
// test length of the received packet
if length != tt.resultLenght { if length != tt.resultLenght {
t.Errorf("Expected length %v, got %v buffer: %v for %s / %s", tt.resultLenght, length, reply[0:length], tt.name, tt.pass) t.Errorf("Expected length %v, got %v buffer: %v for %s / %s", tt.resultLenght, length, reply[0:length], tt.name, tt.pass)
} }
// test content of the packet
assert.Equal(t, reply, tt.resultBuffer, "Login buffers not the same")
}) })
} }
} }