// Returns upper bound key for versions of given byte slice key representation. func (ctx *DataContext) MaxVersionKey(tk TKey) (Key, error) { key := append([]byte{dataKeyPrefix}, ctx.data.InstanceID().Bytes()...) key = append(key, tk...) key = append(key, dvid.VersionID(dvid.MaxVersionID).Bytes()...) key = append(key, dvid.ClientID(dvid.MaxClientID).Bytes()...) return append(key, 0xFF), nil }
func TestRepoGobEncoding(t *testing.T) { uuid := dvid.UUID("19b87f38f873481b9f3ac688877dff0d") versionID := dvid.VersionID(23) repoID := dvid.RepoID(13) repo := newRepo(uuid, versionID, repoID, "foobar") repo.alias = "just some alias" repo.log = []string{ "Did this", "Then that", "And the other thing", } repo.properties = map[string]interface{}{ "foo": 42, "bar": "some string", "baz": []int{3, 9, 7}, } encoding, err := repo.GobEncode() if err != nil { t.Fatalf("Could not encode repo: %v\n", err) } received := repoT{} if err = received.GobDecode(encoding); err != nil { t.Fatalf("Could not decode repo: %v\n", err) } // Did we serialize OK repo.dag = nil received.dag = nil if len(received.properties) != 3 { t.Errorf("Repo Gob messed up properties: %v\n", received.properties) } foo, ok := received.properties["foo"] if !ok || foo != 42 { t.Errorf("Repo Gob messed up properties: %v\n", received.properties) } bar, ok := received.properties["bar"] if !ok || bar != "some string" { t.Errorf("Repo Gob messed up properties: %v\n", received.properties) } baz, ok := received.properties["baz"] if !ok || !reflect.DeepEqual(baz, []int{3, 9, 7}) { t.Errorf("Repo Gob messed up properties: %v\n", received.properties) } repo.properties = nil received.properties = nil if !reflect.DeepEqual(*repo, received) { t.Fatalf("Repo Gob messed up:\nOriginal: %v\nReceived: %v\n", *repo, received) } }