Skip to content
quarry Artifact [8b08af785d]
Login

Artifact [8b08af785d]

Artifact 8b08af785d04544ddff59e51fb18dda646dafd98071a967a3fd054bf0a37fa6e:


package api

import (
	"testing"

	"craftdesign.group/quarry/internal/ops"
	"craftdesign.group/quarry/internal/zitcli"
)

// landing.get names the branch's current tip, so a client can tell the
// forge has taken in a push without finding it in the bounded,
// target-filtered commits list.
func TestLandingGetReturnsTheBranchTip(t *testing.T) {
	dir, ids, ix, pipeSync := premergeStore(t)
	zrun(t, dir, "update", "two")
	zwrite(t, dir, "two.txt", "two\nmore\n")
	zrun(t, dir, "commit", "-m", "more on two", "--user", "u")
	tip := ztip(t, dir, "two")
	if _, err := pipeSync(); err != nil {
		t.Fatal(err)
	}
	r := ops.NewRegistry()
	if err := RegisterAll(r, Deps{Version: "v", LandingNumbers: landingNumberDB(t),
		Repos: NewRepos(map[string]*Repo{"test": {Index: ix, Zit: zitcli.New(dir), Sync: pipeSync}})}); err != nil {
		t.Fatal(err)
	}
	g, err := r.Invoke(as("dan", "i8"), "landing.get", landingGetIn{Repo: "test", ID: ids[1]})
	if err != nil {
		t.Fatal(err)
	}
	if got := g.(landingGetOut).Tip; got != tip {
		t.Errorf("FAIL: tip %q, want %q", got, tip)
	}
	if !t.Failed() {
		t.Log("ok")
	}
}