Files
kopia/repo/object/objectid_test.go
Jarek Kowalski 7c108930ef testing: ensure tests are releasing all buffer pools to reduce memory usage, we had huge leaks (#895)
* testing: ensure tests are releasing all buffer pools to reduce memory usage, we had huge leaks

* object: reduced complexity and memory usage of TestEndToEndReadAndSeekWithCompression

* manifest: more test fixes

* trivial: update comment

Co-authored-by: Julio López <julio+gh@kasten.io>
2021-03-18 06:40:33 -07:00

51 lines
954 B
Go

package object
import (
"testing"
"github.com/kopia/kopia/internal/testutil"
)
func TestMain(m *testing.M) { testutil.MyTestMain(m) }
func TestParseObjectID(t *testing.T) {
cases := []struct {
text string
isValid bool
}{
{"Df0f0", true},
{"IDf0f0", true},
{"IDf0f0", true},
{"IIDf0f0", true},
{"Dxf0f0", true},
{"IDxf0f0", true},
{"IDxf0f0", true},
{"IIDxf0f0", true},
{"Dxf0f", false},
{"IDxf0f", false},
{"Da", false},
{"Daf0f0", false},
{"", false},
{"B!$@#$!@#$", false},
{"X", false},
{"I.", false},
{"I.x", false},
{"I.af", false},
{"Ix.ag", false},
{"Iab.", false},
{"I1", false},
{"I1,", false},
{"I-1,X", false},
{"Xsomething", false},
}
for _, tc := range cases {
_, err := ParseID(tc.text)
if err != nil && tc.isValid {
t.Errorf("error parsing %q: %v", tc.text, err)
} else if err == nil && !tc.isValid {
t.Errorf("unexpected success parsing %v", tc.text)
}
}
}