Skip to content

Commit 516f746

Browse files
committed
First commit: starting on testing upload function in uploader.go
1 parent fd88309 commit 516f746

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

uploader/uploader.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ import (
3131

3232
var filesToUpload [3]string = [3]string{"courses.json", "professors.json", "sections.json"}
3333

34+
// Wrapped for testability - can be replaced with mock in unit tests
35+
var connectDBFunc = func() *mongo.Client {
36+
return connectDB()
37+
}
38+
3439
func Upload(inDir string, replace bool, staticOnly bool) {
3540
//Connect to mongo
36-
client := connectDB()
41+
client := connectDBFunc()
3742

3843
// Get 5 minute context
3944
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)

0 commit comments

Comments
 (0)