Skip to content
quarry Artifact [d9554a6355]
Login

Artifact [d9554a6355]

Artifact d9554a63554afcf6239f54876da10aacbe206411389434f19c76ea4da5726a5f:


package markup

import (
	"strings"
	"testing"
)

type prefetchSpy struct {
	fakeResolver
	calls [][]string
}

func (p *prefetchSpy) PrefetchHashes(hs []string) { p.calls = append(p.calls, hs) }

// A resolver that can take a body's hashes at once is told them once,
// each once, before any is resolved.
func TestResolveRefsPrefetchesEachHashOnce(t *testing.T) {
	a, b := strings.Repeat("a", 40), strings.Repeat("b", 64)
	spy := &prefetchSpy{}
	resolveRefs([]byte("<p>"+a+" then "+b+" and "+a+" again</p>"), spy)
	if len(spy.calls) != 1 || strings.Join(spy.calls[0], ",") != a+","+b {
		t.Errorf("FAIL: prefetch calls %v", spy.calls)
	}
}