package plan

import (
	"strings"
	"testing"
)

func TestCompileRejectsRetiredExpressionNamespacesWithoutAdapter(t *testing.T) {
	for _, root := range []string{"inputs", "event", "steps", "ctx"} {
		t.Run(root, func(t *testing.T) {
			source := strings.Replace(validCallbackPlan, "{{ input.channel }}", "{{ "+root+".channel }}", 1)
			artifact, diagnostics, err := Compile([]byte(source))
			if err != nil {
				t.Fatalf("Compile() error = %v", err)
			}
			if artifact != nil {
				t.Fatalf("Compile() artifact = %#v, want nil", artifact)
			}
			if !hasCode(diagnostics, "expression.unknown_reference") {
				t.Fatalf("Compile() diagnostics = %#v, want expression.unknown_reference", diagnostics)
			}
		})
	}
}
