Skip to content

Commit

Permalink
test add
Browse files Browse the repository at this point in the history
  • Loading branch information
mejgun committed Aug 22, 2020
1 parent 09b674e commit dcd6bae
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions streamer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"errors"
"fmt"
"strings"
"testing"
)

func TestErrorToHeaders(t *testing.T) {
for count := 1; count < 999; count++ {
errStr := "err"
err := errors.New(strings.Repeat(fmt.Sprintf("%s\n \n", errStr), count))
k, v := errorToHeaders(err)
if len(k) != len(v) || len(k) != count {
t.Fatalf("%q*%d should return %d element slices", errStr, count, count)
}
header := fmt.Sprintf("%s0%d", defaultErrorHeader, count)
if header != k[count-1] {
t.Fatalf("%q*%d returned header slice %d element should be %q", errStr, count, count, header)
}
if v[count-1] != errStr {
t.Fatalf("%q*%d should return slice of %q values", errStr, count, errStr)
}
}
}

0 comments on commit dcd6bae

Please sign in to comment.