-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_test.go
40 lines (35 loc) · 1.24 KB
/
db_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"os/exec"
"strings"
"testing"
"fmt"
)
// below is a test for 7 rate my professor links to make sure that the pipeline works correctly.
// see TESTING.md for more instructions
func TestPipeline(t *testing.T) {
urls := []string{
"https://www.ratemyprofessors.com/professor/2946510",
"https://www.ratemyprofessors.com/professor/432142",
"https://www.ratemyprofessors.com/professor/2581017",
"https://www.ratemyprofessors.com/professor/422536",
"https://www.ratemyprofessors.com/professor/2818033",
"https://www.ratemyprofessors.com/professor/354797",
"https://www.ratemyprofessors.com/professor/489006",
}
expectedOutput := "ChromaDB Store Successful!"
for _, url := range urls {
t.Run("Testing URL: "+url, func(t *testing.T) {
cmd := exec.Command("python", "db_store.py", url)
output, err := cmd.CombinedOutput() // <- CombinedOutput() function RUNS the cmd, and then gives us the stdout & the stderr
fmt.Println(string(output))
if err != nil {
t.Fatalf("Failed to run pipeline for URL %s: %v", url, err)
}
outputStr := strings.TrimSpace(string(output))
if outputStr != expectedOutput {
t.Errorf("Unexpected output for URL %s:\nGot: %s\nWant: %s", url, outputStr, expectedOutput)
}
})
}
}