| 21 | } |
| 22 | |
| 23 | func TestRun_NoTemplates(t *testing.T) { |
| 24 | // Create a temp file with just an object (no template) |
| 25 | tmpDir := t.TempDir() |
| 26 | objFile := filepath.Join(tmpDir, "object.yaml") |
| 27 | err := os.WriteFile(objFile, []byte(` |
| 28 | apiVersion: v1 |
| 29 | kind: Pod |
| 30 | metadata: |
| 31 | name: test-pod |
| 32 | `), 0o600) |
| 33 | if err != nil { |
| 34 | t.Fatalf("failed to write test file: %v", err) |
| 35 | } |
| 36 | |
| 37 | _, err = Run(&Opts{ |
| 38 | Filenames: []string{tmpDir}, |
| 39 | Iterations: 1, |
| 40 | Engine: EngineRego, |
| 41 | }) |
| 42 | if err == nil { |
| 43 | t.Error("expected error for missing templates") |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | func TestRun_Integration(t *testing.T) { |
| 48 | // Create temp files with a template, constraint, and object |