package office

import "testing"

func TestDocumentKeyStoreStableWhileActive(t *testing.T) {
	store := newDocumentKeyStore()
	k1 := store.current(99)
	k2 := store.current(99)
	if k1 != k2 {
		t.Fatalf("expected stable key during session, got %q vs %q", k1, k2)
	}
}

func TestDocumentKeyStoreRotatesAfterSave(t *testing.T) {
	store := newDocumentKeyStore()
	before := store.current(7)
	store.rotateAfterSave(7)
	after := store.current(7)
	if before == after {
		t.Fatalf("expected new key after save rotation")
	}
}

func TestDocumentSessionKeyDiffersByFile(t *testing.T) {
	a := documentSessionKey(1, 1)
	b := documentSessionKey(2, 1)
	if a == b {
		t.Fatal("expected different keys for different files")
	}
}
