Skip to content
quarry Artifact [00395c0f62]
Login

Artifact [00395c0f62]

Artifact 00395c0f621311c0581990c7e6c9886db671d745e5c3af4f091d725dff37fbbc:


package oltp

import "testing"

func TestWorkerTokenLedgerRecordsAndForgets(t *testing.T) {
	d := openTest(t)
	if err := d.RecordWorkerToken("h1", "id1", "g-a"); err != nil {
		t.Fatal(err)
	}
	if g, ok := d.WorkerTokenGroup("h1"); !ok || g != "g-a" {
		t.Errorf("FAIL: recorded token reads %q %v", g, ok)
	}
	if _, ok := d.WorkerTokenGroup("other"); ok {
		t.Errorf("FAIL: an unrecorded hash was found")
	}
	if err := d.ForgetWorkerToken("id1"); err != nil {
		t.Fatal(err)
	}
	if _, ok := d.WorkerTokenGroup("h1"); ok {
		t.Errorf("FAIL: a forgotten token is still recorded")
	}
	if !t.Failed() {
		t.Log("ok")
	}
}