pkg/auth and pkg/schema: fix tests.

Change-Id: I54f391241c77902ad301edea92d39660f7cf0008
This commit is contained in:
Brad Fitzpatrick 2012-03-29 16:15:59 -07:00
parent 55edf14a70
commit 40712671ee
3 changed files with 3 additions and 50 deletions

View File

@ -19,7 +19,6 @@ package auth
import (
"encoding/base64"
"fmt"
"log"
"net/http"
"os"
"regexp"

View File

@ -59,11 +59,11 @@ func filePart(cps []*BytesPart, skip uint64) *BytesPart {
}
err := PopulateParts(m, fileSize, cpl)
if err != nil {
panic(err.String())
panic(err)
}
json, err := MapToCamliJson(m)
if err != nil {
panic(err.String())
panic(err)
}
tb := &test.Blob{json}
testFetcher.AddBlob(tb)

View File

@ -22,28 +22,9 @@ import (
"strings"
"testing"
. "camli/test/asserts"
. "camlistore.org/pkg/test/asserts"
)
type isUtf8Test struct {
s string
e bool
}
func TestIsUtf8(t *testing.T) {
tests := []isUtf8Test{
{"foo", true},
{"Straße", true},
{string([]uint8{65, 234, 234, 192, 23, 123}), false},
{string([]uint8{65, 97}), true},
}
for idx, test := range tests {
if isValidUtf8(test.s) != test.e {
t.Errorf("expected isutf8==%d for test index %d", test.e, idx)
}
}
}
const kExpectedHeader = `{"camliVersion"`
func TestJson(t *testing.T) {
@ -63,33 +44,6 @@ func TestJson(t *testing.T) {
}
type rfc3339NanoTest struct {
nanos int64
e string
}
func TestRFC3339Nanos(t *testing.T) {
tests := []rfc3339NanoTest{
{0, "1970-01-01T00:00:00Z"},
{1, "1970-01-01T00:00:00.000000001Z"},
{10, "1970-01-01T00:00:00.00000001Z"},
{1000, "1970-01-01T00:00:00.000001Z"},
{1301114560 * 1e9, "2011-03-26T04:42:40Z"},
{1301114560*1e9 + 10, "2011-03-26T04:42:40.00000001Z"},
}
for idx, test := range tests {
got := RFC3339FromNanos(test.nanos)
if got != test.e {
t.Errorf("On test %d got %q; expected %q", idx, got, test.e)
}
// and back!
back := NanosFromRFC3339(test.e)
if back != test.nanos {
t.Errorf("On test %d NanosFromRFC3339(%q) got %d; expected %d", idx, test.e, back, test.nanos)
}
}
}
func TestRegularFile(t *testing.T) {
fileName := "schema_test.go"
fi, err := os.Lstat(fileName)