// extends handlerDescribeTestSetup but adds a camliContentImage to pn.
func handlerDescribeTestSetupWithImage(fi *test.FakeIndex) index.Interface {
	handlerDescribeTestSetup(fi)
	pn := blob.MustParse("perma-123")
	imageRef := blob.MustParse("fakeref-789")
	fi.AddMeta(imageRef, "", 789)
	fi.AddClaim(owner, pn, "set-attribute", "camliContentImage", imageRef.String())
	return fi
}
func addPermanode(fi *test.FakeIndex, pnStr string, attrs ...string) {
	pn := blob.MustParse(pnStr)
	fi.AddMeta(pn, "permanode", 123)
	for len(attrs) > 0 {
		k, v := attrs[0], attrs[1]
		attrs = attrs[2:]
		fi.AddClaim(owner, pn, "add-attribute", k, v)
	}
}
func handlerDescribeTestSetup(fi *test.FakeIndex) index.Interface {
	pn := blob.MustParse("perma-123")
	fi.AddMeta(pn, "permanode", 123)
	fi.AddClaim(owner, pn, "set-attribute", "camliContent", "fakeref-232")
	fi.AddMeta(blob.MustParse("fakeref-232"), "", 878)

	// Test deleting all attributes
	fi.AddClaim(owner, pn, "add-attribute", "wont-be-present", "x")
	fi.AddClaim(owner, pn, "add-attribute", "wont-be-present", "y")
	fi.AddClaim(owner, pn, "del-attribute", "wont-be-present", "")

	// Test deleting a specific attribute.
	fi.AddClaim(owner, pn, "add-attribute", "only-delete-b", "a")
	fi.AddClaim(owner, pn, "add-attribute", "only-delete-b", "b")
	fi.AddClaim(owner, pn, "add-attribute", "only-delete-b", "c")
	fi.AddClaim(owner, pn, "del-attribute", "only-delete-b", "b")
	return fi
}
// extends handlerDescribeTestSetup but adds various embedded references to other nodes.
func handlerDescribeTestSetupWithEmbeddedRefs(fi *test.FakeIndex) index.Interface {
	handlerDescribeTestSetup(fi)
	pn := blob.MustParse("perma-123")
	c1 := blob.MustParse("fakeref-01")
	c2 := blob.MustParse("fakeref-02")
	c3 := blob.MustParse("fakeref-03")
	c4 := blob.MustParse("fakeref-04")
	c5 := blob.MustParse("fakeref-05")
	c6 := blob.MustParse("fakeref-06")
	fi.AddMeta(c1, "", 1)
	fi.AddMeta(c2, "", 2)
	fi.AddMeta(c3, "", 3)
	fi.AddMeta(c4, "", 4)
	fi.AddMeta(c5, "", 5)
	fi.AddMeta(c6, "", 6)
	fi.AddClaim(owner, pn, "set-attribute", c1.String(), "foo")
	fi.AddClaim(owner, pn, "set-attribute", "foo,"+c2.String()+"=bar", "foo")
	fi.AddClaim(owner, pn, "set-attribute", "foo:"+c3.String()+"?bar,"+c4.String(), "foo")
	fi.AddClaim(owner, pn, "set-attribute", "foo", c5.String())
	fi.AddClaim(owner, pn, "add-attribute", "bar", "baz")
	fi.AddClaim(owner, pn, "add-attribute", "bar", "monkey\n"+c6.String())
	return fi
}