package xrpc

import (
	"fmt"
	"testing"

	"github.com/alecthomas/assert/v2"
	"github.com/bluesky-social/indigo/atproto/syntax"
)

func TestEscapeGitRef(t *testing.T) {
	recordDID := syntax.DID("did:plc:alice")
	record := syntax.ATURI("at://did:plc:alice/sh.tangled.repo.pull/something")
	commitID := "what"
	refName := EscapeGitRef(fmt.Sprintf("refs/tngl/keep/%s/%s/%s/%s", recordDID.String(), record.Collection(), record.RecordKey(), commitID))
	assert.Equal(t, "refs/tngl/keep/did%3aplc%3aalice/sh.tangled.repo.pull/something/what", refName)
}
