fix unit tests

master
Jordan Orelli 11 years ago
parent 61947ead11
commit 1740f13db8

@ -47,7 +47,8 @@ func main() {
defer conn.Close()
if options.password != "" {
fmt.Fprintf(conn, "*2\r\n$4\r\nauth\r\n$%d\r\n%s\r\n", len(options.password), options.password)
auth(options.password).Write(conn)
// fmt.Fprintf(conn, "*2\r\n$4\r\nauth\r\n$%d\r\n%s\r\n", len(options.password), options.password)
v, err := readValue(conn)
if err != nil {
fmt.Printf("unable to auth: %v\n", err)
@ -67,7 +68,7 @@ func main() {
defer infile.Close()
c, e := make(chan value), make(chan error)
sent := make(chan value, 1)
sent := make(chan value)
go streamValues(infile, c, e)
go func() {
for {

@ -19,6 +19,10 @@ type value interface {
Write(io.Writer) (int, error)
}
func auth(password string) value {
return Array{BulkString("auth"), BulkString(password)}
}
func isOK(v value) bool {
vv, ok := v.(String)
if !ok {

@ -127,18 +127,22 @@ var streamTests = []streamTest{
}
func (s streamTest) run(t *testing.T) {
in, out := s[0].(string), make([]value, len(s)-1)
for i := 1; i < len(s); i++ {
out[i-1] = s[i].(value)
}
c, e := make(chan value), make(chan error)
r := strings.NewReader(s[0].(string))
go streamValues(r, c, e)
count := 1
go streamValues(strings.NewReader(in), c, e)
var count int
for {
select {
case v, ok := <-c:
if !ok {
return
}
if !eq(s[count], v) {
t.Errorf("expected %q, got %q", s[count], v)
if !eq(out[count], v) {
t.Errorf("expected %q, got %q", out[count], v)
}
case err, ok := <-e:
if !ok {

Loading…
Cancel
Save