Merge pull request #10413 from dolthub/db/gitblobstore

/go/store/{blobstore,nbs,testutils}: add ref constants
This commit is contained in:
Dustin Brown
2026-02-04 11:27:20 -08:00
committed by GitHub
4 changed files with 41 additions and 12 deletions
+9 -9
View File
@@ -35,7 +35,7 @@ func TestGitBlobstore_RefMissingIsNotFound(t *testing.T) {
repo, err := gitrepo.InitBare(ctx, t.TempDir()+"/repo.git")
require.NoError(t, err)
bs, err := NewGitBlobstore(repo.GitDir, "refs/dolt/data")
bs, err := NewGitBlobstore(repo.GitDir, DoltDataRef)
require.NoError(t, err)
ok, err := bs.Exists(ctx, "manifest")
@@ -64,13 +64,13 @@ func TestGitBlobstore_ExistsAndGet_AllRange(t *testing.T) {
require.NoError(t, err)
want := []byte("hello manifest\n")
commit, err := repo.SetRefToTree(ctx, "refs/dolt/data", map[string][]byte{
commit, err := repo.SetRefToTree(ctx, DoltDataRef, map[string][]byte{
"manifest": want,
"dir/file": []byte("abc"),
}, "seed")
require.NoError(t, err)
bs, err := NewGitBlobstore(repo.GitDir, "refs/dolt/data")
bs, err := NewGitBlobstore(repo.GitDir, DoltDataRef)
require.NoError(t, err)
ok, err := bs.Exists(ctx, "manifest")
@@ -108,12 +108,12 @@ func TestGitBlobstore_Get_NotFoundMissingKey(t *testing.T) {
repo, err := gitrepo.InitBare(ctx, t.TempDir()+"/repo.git")
require.NoError(t, err)
_, err = repo.SetRefToTree(ctx, "refs/dolt/data", map[string][]byte{
_, err = repo.SetRefToTree(ctx, DoltDataRef, map[string][]byte{
"present": []byte("x"),
}, "seed")
require.NoError(t, err)
bs, err := NewGitBlobstore(repo.GitDir, "refs/dolt/data")
bs, err := NewGitBlobstore(repo.GitDir, DoltDataRef)
require.NoError(t, err)
_, _, err = GetBytes(ctx, bs, "missing", AllRange)
@@ -133,12 +133,12 @@ func TestGitBlobstore_BlobRangeSemantics(t *testing.T) {
maxValue := int64(16 * 1024)
testData := rangeData(0, maxValue)
commit, err := repo.SetRefToTree(ctx, "refs/dolt/data", map[string][]byte{
commit, err := repo.SetRefToTree(ctx, DoltDataRef, map[string][]byte{
"range": testData,
}, "range fixture")
require.NoError(t, err)
bs, err := NewGitBlobstore(repo.GitDir, "refs/dolt/data")
bs, err := NewGitBlobstore(repo.GitDir, DoltDataRef)
require.NoError(t, err)
// full range
@@ -181,10 +181,10 @@ func TestGitBlobstore_InvalidKeysError(t *testing.T) {
repo, err := gitrepo.InitBare(ctx, t.TempDir()+"/repo.git")
require.NoError(t, err)
_, err = repo.SetRefToTree(ctx, "refs/dolt/data", map[string][]byte{"ok": []byte("x")}, "seed")
_, err = repo.SetRefToTree(ctx, DoltDataRef, map[string][]byte{"ok": []byte("x")}, "seed")
require.NoError(t, err)
bs, err := NewGitBlobstore(repo.GitDir, "refs/dolt/data")
bs, err := NewGitBlobstore(repo.GitDir, DoltDataRef)
require.NoError(t, err)
invalid := []string{
+27
View File
@@ -0,0 +1,27 @@
// Copyright 2026 Dolthub, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package blobstore
import "fmt"
// DoltDataRef is the local writable ref backing a git-object-db dolt blobstore.
// It is the state that local operations mutate and (eventually) attempt to push.
const DoltDataRef = "refs/dolt/data"
// DoltRemoteTrackingDataRef returns the remote-tracking ref for a named remote.
// This ref represents the remote's DoltDataRef as of the last fetch.
func DoltRemoteTrackingDataRef(remote string) string {
return fmt.Sprintf("refs/dolt/remotes/%s/data", remote)
}
@@ -58,14 +58,14 @@ func TestGitBlobstoreReadSmoke_ManifestAndTableAccessPatterns(t *testing.T) {
table[i] = byte(i % 251)
}
commit, err := repo.SetRefToTree(ctx, "refs/dolt/data", map[string][]byte{
commit, err := repo.SetRefToTree(ctx, blobstore.DoltDataRef, map[string][]byte{
"manifest": buf.Bytes(),
"table": table,
}, "seed refs/dolt/data for smoke test")
require.NoError(t, err)
require.NotEmpty(t, commit)
bs, err := blobstore.NewGitBlobstore(repo.GitDir, "refs/dolt/data")
bs, err := blobstore.NewGitBlobstore(repo.GitDir, blobstore.DoltDataRef)
require.NoError(t, err)
// 1) Manifest read path via blobstoreManifest.ParseIfExists.
+3 -1
View File
@@ -20,6 +20,8 @@ import (
"path/filepath"
"strings"
"testing"
"github.com/dolthub/dolt/go/store/blobstore"
)
func TestInitBareAndSetRefToTree(t *testing.T) {
@@ -36,7 +38,7 @@ func TestInitBareAndSetRefToTree(t *testing.T) {
t.Fatalf("InitBare failed: %v", err)
}
commit, err := repo.SetRefToTree(ctx, "refs/dolt/data", map[string][]byte{
commit, err := repo.SetRefToTree(ctx, blobstore.DoltDataRef, map[string][]byte{
"manifest": []byte("hello\n"),
"dir/file": []byte("abc"),
"dir/file2": []byte("def"),