package runtimeapi

import (
	"os"
	"strings"
	"testing"
)

// The read graph's ContractService happens to expose mutation methods, so a
// compile-time interface check cannot detect this production wiring mistake.
// Keep the owning graph invariant executable until those interfaces are split.
func TestProductionRecycleBinMutationUsesTheCompleteMutationGraph(t *testing.T) {
	source, err := os.ReadFile("process.go")
	if err != nil {
		t.Fatal(err)
	}
	body := string(source)
	if strings.Contains(body, "config.RecycleBinMutator = readGraph.Records") {
		t.Fatal("production recycle-bin mutations were wired to the transaction-incomplete read graph")
	}
	for _, required := range []string{
		"recycleBinMutationEnabled := config.RecycleBinMutationMaxAdmissionLease > 0",
		"needsPrivateListViews || recycleBinMutationEnabled",
		"config.RecycleBinMutator = mutationGraph.Records",
	} {
		if !strings.Contains(body, required) {
			t.Fatalf("production recycle-bin mutation graph invariant is missing %q", required)
		}
	}
}
