refactor: remove golden file from quickstart tests

This commit is contained in:
Twisha Bansal
2026-02-11 14:44:29 +05:30
parent 1f8019c50a
commit 03abf943e8
4 changed files with 8 additions and 29 deletions

View File

@@ -20,6 +20,8 @@ import (
"testing"
)
var goldenKeywords = []string{"Hilton Basel", "Hyatt Regency", "book"}
func TestQuickstartSample(t *testing.T) {
framework := os.Getenv("ORCH_NAME")
if framework == "" {
@@ -59,16 +61,10 @@ func TestQuickstartSample(t *testing.T) {
t.Fatal("Script ran successfully but produced no output.")
}
goldenFile, err := os.ReadFile("../golden.txt")
if err != nil {
t.Fatalf("Could not read golden.txt to check for keywords: %v", err)
}
keywords := strings.Split(string(goldenFile), "\n")
var missingKeywords []string
outputLower := strings.ToLower(actualOutput)
for _, keyword := range keywords {
for _, keyword := range goldenKeywords {
kw := strings.TrimSpace(keyword)
if kw != "" && !strings.Contains(outputLower, strings.ToLower(kw)) {
missingKeywords = append(missingKeywords, kw)

View File

@@ -1,3 +0,0 @@
Hilton Basel
Hyatt Regency
book

View File

@@ -25,7 +25,7 @@ const quickstartPath = path.join(orchDir, "quickstart.js");
const { main: runAgent } = await import(quickstartPath);
const GOLDEN_FILE_PATH = path.resolve(__dirname, "../golden.txt");
const GOLDEN_KEYWORDS = ["Hilton Basel", "Hyatt Regency", "book"];
describe(`${ORCH_NAME} Quickstart Agent`, () => {
let capturedOutput = [];
@@ -52,11 +52,8 @@ describe(`${ORCH_NAME} Quickstart Agent`, () => {
"Assertion Failed: Script ran successfully but produced no output."
);
const goldenFile = fs.readFileSync(GOLDEN_FILE_PATH, "utf8");
const keywords = goldenFile.split("\n").filter((kw) => kw.trim() !== "");
const missingKeywords = [];
for (const keyword of keywords) {
for (const keyword of GOLDEN_KEYWORDS) {
if (!actualOutput.toLowerCase().includes(keyword.toLowerCase())) {
missingKeywords.push(keyword);
}

View File

@@ -24,18 +24,7 @@ module_path = f"python.{ORCH_NAME}.quickstart"
quickstart = importlib.import_module(module_path)
@pytest.fixture(scope="module")
def golden_keywords():
"""Loads expected keywords from the golden.txt file."""
golden_file_path = Path("../golden.txt")
if not golden_file_path.exists():
pytest.fail(f"Golden file not found: {golden_file_path}")
try:
with open(golden_file_path, 'r') as f:
return [line.strip() for line in f.readlines() if line.strip()]
except Exception as e:
pytest.fail(f"Could not read golden.txt: {e}")
GOLDEN_KEYWORDS = ["Hilton Basel", "Hyatt Regency", "book"]
# --- Execution Tests ---
class TestExecution:
@@ -62,8 +51,8 @@ class TestExecution:
"""Test that the script runs and produces no stderr."""
assert script_output.err == "", f"Script produced stderr: {script_output.err}"
def test_keywords_in_output(self, script_output, golden_keywords):
def test_keywords_in_output(self, script_output):
"""Test that expected keywords are present in the script's output."""
output = script_output.out
missing_keywords = [kw for kw in golden_keywords if kw not in output]
missing_keywords = [kw for kw in GOLDEN_KEYWORDS if kw not in output]
assert not missing_keywords, f"Missing keywords in output: {missing_keywords}"