mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-24 03:16:12 -05:00
Merge pull request #10413 from dolthub/db/gitblobstore
/go/store/{blobstore,nbs,testutils}: add ref constants
This commit is contained in:
@@ -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{
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user