From 516f746e6c9bb4a033f2b0fa1e0fcac8ccb421a5 Mon Sep 17 00:00:00 2001 From: Flavore669 Date: Wed, 15 Oct 2025 00:13:54 -0500 Subject: [PATCH 1/5] First commit: starting on testing upload function in uploader.go --- uploader/uploader.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/uploader/uploader.go b/uploader/uploader.go index 85dac86..d980cde 100644 --- a/uploader/uploader.go +++ b/uploader/uploader.go @@ -31,9 +31,14 @@ import ( var filesToUpload [3]string = [3]string{"courses.json", "professors.json", "sections.json"} +// Wrapped for testability - can be replaced with mock in unit tests +var connectDBFunc = func() *mongo.Client { + return connectDB() +} + func Upload(inDir string, replace bool, staticOnly bool) { //Connect to mongo - client := connectDB() + client := connectDBFunc() // Get 5 minute context ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) From d61be41b5128cdf2ee3def55894a20053accb547 Mon Sep 17 00:00:00 2001 From: Flavore669 Date: Wed, 15 Oct 2025 00:21:30 -0500 Subject: [PATCH 2/5] minor changes --- uploader/uploader_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 uploader/uploader_test.go diff --git a/uploader/uploader_test.go b/uploader/uploader_test.go new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/uploader/uploader_test.go @@ -0,0 +1,16 @@ +package uploader + +import ( + "testing" + + "go.mongodb.org/mongo-driver/mongo" +) + +func TestUpload(t *testing.T) { + connectDBFunc = func() *mongo.Client { + return nil // Simple mock, no real connection to db + } + defer func() { connectDBFunc = connectDB }() // Point back to original connectDB for any subsequent tests + + Upload("/test", false, true) +} From 68d4255752f9a49c10e0819d5cd8994859fe8571 Mon Sep 17 00:00:00 2001 From: Flavore669 Date: Sun, 26 Oct 2025 23:28:31 -0500 Subject: [PATCH 3/5] created test infrastructure --- .../uploader-tests/test_courses.json | 13 ++++++ .../uploader-tests/test_professors.json | 5 +++ .../uploader-tests/test_sections.json | 7 +++ uploader/uploader_test.go | 43 +++++++++++++++++-- 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 uploader/test-data/uploader-tests/test_courses.json create mode 100644 uploader/test-data/uploader-tests/test_professors.json create mode 100644 uploader/test-data/uploader-tests/test_sections.json diff --git a/uploader/test-data/uploader-tests/test_courses.json b/uploader/test-data/uploader-tests/test_courses.json new file mode 100644 index 0000000..d6607ce --- /dev/null +++ b/uploader/test-data/uploader-tests/test_courses.json @@ -0,0 +1,13 @@ +[{ + "_id": "test_course_1", + "subject_prefix": "TEST", + "course_number": "1000", + "title": "Test Course", + "description": "Test course description", + "school": "Test School", + "credit_hours": "3", + "class_level": "Undergraduate", + "activity_type": "Lecture", + "catalog_year": "24", + "sections": [] +}] \ No newline at end of file diff --git a/uploader/test-data/uploader-tests/test_professors.json b/uploader/test-data/uploader-tests/test_professors.json new file mode 100644 index 0000000..3f97888 --- /dev/null +++ b/uploader/test-data/uploader-tests/test_professors.json @@ -0,0 +1,5 @@ +[{ + "_id": "test_prof_1", + "first_name": "Test", + "last_name": "Professor" +}] \ No newline at end of file diff --git a/uploader/test-data/uploader-tests/test_sections.json b/uploader/test-data/uploader-tests/test_sections.json new file mode 100644 index 0000000..9452f7c --- /dev/null +++ b/uploader/test-data/uploader-tests/test_sections.json @@ -0,0 +1,7 @@ +[{ + "_id": "test_section_1", + "section_number": "001", + "course_reference": "test_course_1", + "academic_session": "spring2024", + "professors": ["test_prof_1"] +}] \ No newline at end of file diff --git a/uploader/uploader_test.go b/uploader/uploader_test.go index d36b1fa..b065c01 100644 --- a/uploader/uploader_test.go +++ b/uploader/uploader_test.go @@ -7,10 +7,47 @@ import ( ) func TestUpload(t *testing.T) { + // Save original function and restore after test + originalConnectDB := connectDBFunc + defer func() { connectDBFunc = originalConnectDB }() + + // Create a simple mock that returns nil (or a minimal mock client) connectDBFunc = func() *mongo.Client { - return nil // Simple mock, no real connection to db + return nil + } + + // Test cases + tests := []struct { + name string + inDir string + replace bool + staticOnly bool + }{ + { + name: "static only mode", + inDir: "./testdata", + replace: false, + staticOnly: true, + }, + { + name: "full upload with replace", + inDir: "./testdata", + replace: true, + staticOnly: false, + }, } - defer func() { connectDBFunc = connectDB }() // Point back to original connectDB for any subsequent tests - Upload("/test", false, true) + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + // This will panic when it tries to use the nil client, but that's fine for now + // The goal is to test that the function calls what it should call + defer func() { + if r := recover(); r != nil { + t.Logf("Expected panic when database operations are attempted: %v", r) + } + }() + + Upload(tt.inDir, tt.replace, tt.staticOnly) + }) + } } From 68b7b25cc49051ee61eaf8a17d03485393a80a9d Mon Sep 17 00:00:00 2001 From: Flavore669 Date: Sun, 2 Nov 2025 15:35:46 -0600 Subject: [PATCH 4/5] Added Test Cases. Next I will modify uplodader_test.go to test each case --- .../uploader-tests/test_courses.json | 13 ---- .../uploader-tests/test_professors.json | 5 -- .../uploader-tests/test_sections.json | 7 -- .../uploader.go-tests/case_basic/courses.json | 25 +++++++ .../case_basic/professors.json | 15 +++++ .../case_basic/sections.json | 32 +++++++++ .../uploader.go-tests/case_edge/courses.json | 25 +++++++ .../case_edge/professors.json | 1 + .../uploader.go-tests/case_edge/sections.json | 1 + .../case_multiple/courses.json | 25 +++++++ .../case_multiple/professors.json | 15 +++++ .../case_multiple/sections.json | 66 +++++++++++++++++++ .../case_relationship/courses.json | 13 ++++ .../case_relationship/professors.json | 18 +++++ .../case_relationship/sections.json | 1 + .../case_sorting/courses.json | 38 +++++++++++ .../case_sorting/professors.json | 1 + .../case_sorting/sections.json | 1 + uploader/uploader_test.go | 1 + 19 files changed, 278 insertions(+), 25 deletions(-) delete mode 100644 uploader/test-data/uploader-tests/test_courses.json delete mode 100644 uploader/test-data/uploader-tests/test_professors.json delete mode 100644 uploader/test-data/uploader-tests/test_sections.json create mode 100644 uploader/testdata/uploader.go-tests/case_basic/courses.json create mode 100644 uploader/testdata/uploader.go-tests/case_basic/professors.json create mode 100644 uploader/testdata/uploader.go-tests/case_basic/sections.json create mode 100644 uploader/testdata/uploader.go-tests/case_edge/courses.json create mode 100644 uploader/testdata/uploader.go-tests/case_edge/professors.json create mode 100644 uploader/testdata/uploader.go-tests/case_edge/sections.json create mode 100644 uploader/testdata/uploader.go-tests/case_multiple/courses.json create mode 100644 uploader/testdata/uploader.go-tests/case_multiple/professors.json create mode 100644 uploader/testdata/uploader.go-tests/case_multiple/sections.json create mode 100644 uploader/testdata/uploader.go-tests/case_relationship/courses.json create mode 100644 uploader/testdata/uploader.go-tests/case_relationship/professors.json create mode 100644 uploader/testdata/uploader.go-tests/case_relationship/sections.json create mode 100644 uploader/testdata/uploader.go-tests/case_sorting/courses.json create mode 100644 uploader/testdata/uploader.go-tests/case_sorting/professors.json create mode 100644 uploader/testdata/uploader.go-tests/case_sorting/sections.json diff --git a/uploader/test-data/uploader-tests/test_courses.json b/uploader/test-data/uploader-tests/test_courses.json deleted file mode 100644 index d6607ce..0000000 --- a/uploader/test-data/uploader-tests/test_courses.json +++ /dev/null @@ -1,13 +0,0 @@ -[{ - "_id": "test_course_1", - "subject_prefix": "TEST", - "course_number": "1000", - "title": "Test Course", - "description": "Test course description", - "school": "Test School", - "credit_hours": "3", - "class_level": "Undergraduate", - "activity_type": "Lecture", - "catalog_year": "24", - "sections": [] -}] \ No newline at end of file diff --git a/uploader/test-data/uploader-tests/test_professors.json b/uploader/test-data/uploader-tests/test_professors.json deleted file mode 100644 index 3f97888..0000000 --- a/uploader/test-data/uploader-tests/test_professors.json +++ /dev/null @@ -1,5 +0,0 @@ -[{ - "_id": "test_prof_1", - "first_name": "Test", - "last_name": "Professor" -}] \ No newline at end of file diff --git a/uploader/test-data/uploader-tests/test_sections.json b/uploader/test-data/uploader-tests/test_sections.json deleted file mode 100644 index 9452f7c..0000000 --- a/uploader/test-data/uploader-tests/test_sections.json +++ /dev/null @@ -1,7 +0,0 @@ -[{ - "_id": "test_section_1", - "section_number": "001", - "course_reference": "test_course_1", - "academic_session": "spring2024", - "professors": ["test_prof_1"] -}] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_basic/courses.json b/uploader/testdata/uploader.go-tests/case_basic/courses.json new file mode 100644 index 0000000..720d623 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_basic/courses.json @@ -0,0 +1,25 @@ +[ + { + "_id": "67d07ee0c972c18731e23bee", + "subject_prefix": "BA", + "course_number": "1320", + "title": "Business in a Global World", + "description": "BA 1320 - Business in a Global World (3 semester credit hours) This course provides a primer on the impacts of globalization on business.", + "enrollment_reqs": "BA 1320 Repeat Restriction", + "school": "Naveen Jindal School of Management", + "credit_hours": "3", + "class_level": "Undergraduate", + "activity_type": "Lecture", + "grading": "Graded - Undergraduate", + "internal_course_number": "015444", + "prerequisites": null, + "corequisites": null, + "co_or_pre_requisites": null, + "sections": ["67d07ee0c972c18731e23bef"], + "lecture_contact_hours": "3", + "laboratory_contact_hours": "0", + "offering_frequency": "S", + "catalog_year": "24", + "attributes": null + } +] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_basic/professors.json b/uploader/testdata/uploader.go-tests/case_basic/professors.json new file mode 100644 index 0000000..79806d9 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_basic/professors.json @@ -0,0 +1,15 @@ +[ + { + "_id": "67d07ee0c972c18731e23bf0", + "first_name": "Peter", + "last_name": "Lewin", + "titles": ["Primary Instructor"], + "email": "plewin@utdallas.edu", + "phone_number": "", + "office": {"building": "", "room": "", "map_uri": ""}, + "profile_uri": "", + "image_uri": "", + "office_hours": null, + "sections": ["67d07ee0c972c18731e23bef"] + } +] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_basic/sections.json b/uploader/testdata/uploader.go-tests/case_basic/sections.json new file mode 100644 index 0000000..d1b9b43 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_basic/sections.json @@ -0,0 +1,32 @@ +[ + { + "_id": "67d07ee0c972c18731e23bef", + "section_number": "501", + "course_reference": "67d07ee0c972c18731e23bee", + "section_corequisites": null, + "academic_session": { + "name": "25S", + "start_date": "2025-01-21T00:00:00-06:00", + "end_date": "2025-05-16T00:00:00-05:00" + }, + "professors": ["67d07ee0c972c18731e23bf0"], + "teaching_assistants": [], + "internal_class_number": "27195", + "instruction_mode": "Face-to-Face", + "meetings": [ + { + "start_date": "2025-01-21T00:00:00-06:00", + "end_date": "2025-05-09T00:00:00-05:00", + "meeting_days": ["Tuesday", "Thursday"], + "start_time": "5:30pm", + "end_time": "6:45pm", + "modality": "", + "location": {"building": "JSOM", "room": "12.218", "map_uri": "https://locator.utdallas.edu/SOM_12.218"} + } + ], + "core_flags": ["080", "090"], + "syllabus_uri": "https://dox.utdallas.edu/syl153033", + "grade_distribution": [], + "attributes": null + } +] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_edge/courses.json b/uploader/testdata/uploader.go-tests/case_edge/courses.json new file mode 100644 index 0000000..17977d8 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_edge/courses.json @@ -0,0 +1,25 @@ +[ + { + "_id": "67d07ee0c972c18731e23bf4", + "subject_prefix": "AERO", + "course_number": "3320", + "title": "- Recitation", + "description": "- ()", + "enrollment_reqs": "", + "school": "Undergraduate Studies", + "credit_hours": "Non-Enroll", + "class_level": "Undergraduate", + "activity_type": "Laboratory - No Lab Fee", + "grading": "Graded - Undergraduate", + "internal_course_number": "000243", + "prerequisites": null, + "corequisites": null, + "co_or_pre_requisites": null, + "sections": ["67d07ee0c972c18731e23bf5"], + "lecture_contact_hours": "", + "laboratory_contact_hours": "", + "offering_frequency": "", + "catalog_year": "24", + "attributes": null + } +] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_edge/professors.json b/uploader/testdata/uploader.go-tests/case_edge/professors.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_edge/professors.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_edge/sections.json b/uploader/testdata/uploader.go-tests/case_edge/sections.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_edge/sections.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_multiple/courses.json b/uploader/testdata/uploader.go-tests/case_multiple/courses.json new file mode 100644 index 0000000..c91310d --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_multiple/courses.json @@ -0,0 +1,25 @@ +[ + { + "_id": "67d07ee0c972c18731e23be9", + "subject_prefix": "ACCT", + "course_number": "2301", + "title": "Introductory Financial Accounting", + "description": "ACCT 2301 - Introductory Financial Accounting (3 semester credit hours) An introduction to financial reporting...", + "enrollment_reqs": "ACCT 2301 Repeat Restriction", + "school": "Naveen Jindal School of Management", + "credit_hours": "3", + "class_level": "Undergraduate", + "activity_type": "Lecture", + "grading": "Graded - Undergraduate", + "internal_course_number": "000061", + "prerequisites": null, + "corequisites": null, + "co_or_pre_requisites": null, + "sections": ["67d07ee0c972c18731e23bea", "67d07ee0c972c18731e23bed"], + "lecture_contact_hours": "3", + "laboratory_contact_hours": "0", + "offering_frequency": "S", + "catalog_year": "24", + "attributes": null + } +] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_multiple/professors.json b/uploader/testdata/uploader.go-tests/case_multiple/professors.json new file mode 100644 index 0000000..b6f627b --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_multiple/professors.json @@ -0,0 +1,15 @@ +[ + { + "_id": "67d07ee0c972c18731e23beb", + "first_name": "Naim Bugra", + "last_name": "Ozel", + "titles": ["Primary Instructor (50%)"], + "email": "nbo150030@utdallas.edu", + "phone_number": "", + "office": {"building": "", "room": "", "map_uri": ""}, + "profile_uri": "", + "image_uri": "", + "office_hours": null, + "sections": ["67d07ee0c972c18731e23bea", "67d07ee0c972c18731e23bed"] + } +] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_multiple/sections.json b/uploader/testdata/uploader.go-tests/case_multiple/sections.json new file mode 100644 index 0000000..8bd812a --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_multiple/sections.json @@ -0,0 +1,66 @@ +[ + { + "_id": "67d07ee0c972c18731e23bea", + "section_number": "003", + "course_reference": "67d07ee0c972c18731e23be9", + "section_corequisites": null, + "academic_session": { + "name": "25S", + "start_date": "2025-01-21T00:00:00-06:00", + "end_date": "2025-05-16T00:00:00-05:00" + }, + "professors": ["67d07ee0c972c18731e23beb"], + "teaching_assistants": [ + {"first_name": "Galymzhan", "last_name": "Tazhibayev", "role": "Teaching Assistant", "email": "gxt230023@utdallas.edu"} + ], + "internal_class_number": "27706", + "instruction_mode": "Face-to-Face", + "meetings": [ + { + "start_date": "2025-01-21T00:00:00-06:00", + "end_date": "2025-05-09T00:00:00-05:00", + "meeting_days": ["Tuesday", "Thursday"], + "start_time": "10:00am", + "end_time": "11:15am", + "modality": "", + "location": {"building": "JSOM", "room": "2.717", "map_uri": "https://locator.utdallas.edu/SOM_2.717"} + } + ], + "core_flags": [], + "syllabus_uri": "https://dox.utdallas.edu/syl152555", + "grade_distribution": [], + "attributes": null + }, + { + "_id": "67d07ee0c972c18731e23bed", + "section_number": "001", + "course_reference": "67d07ee0c972c18731e23be9", + "section_corequisites": null, + "academic_session": { + "name": "25S", + "start_date": "2025-01-21T00:00:00-06:00", + "end_date": "2025-05-16T00:00:00-05:00" + }, + "professors": ["67d07ee0c972c18731e23beb"], + "teaching_assistants": [ + {"first_name": "Galymzhan", "last_name": "Tazhibayev", "role": "Teaching Assistant", "email": "gxt230023@utdallas.edu"} + ], + "internal_class_number": "26595", + "instruction_mode": "Face-to-Face", + "meetings": [ + { + "start_date": "2025-01-21T00:00:00-06:00", + "end_date": "2025-05-09T00:00:00-05:00", + "meeting_days": ["Tuesday", "Thursday"], + "start_time": "8:30am", + "end_time": "9:45am", + "modality": "", + "location": {"building": "JSOM", "room": "2.717", "map_uri": "https://locator.utdallas.edu/SOM_2.717"} + } + ], + "core_flags": [], + "syllabus_uri": "https://dox.utdallas.edu/syl152552", + "grade_distribution": [], + "attributes": null + } +] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_relationship/courses.json b/uploader/testdata/uploader.go-tests/case_relationship/courses.json new file mode 100644 index 0000000..5a3cf56 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_relationship/courses.json @@ -0,0 +1,13 @@ +[ + { + "_id": "67d07ee0c972c18731e23be9", + "subject_prefix": "ACCT", + "course_number": "2301", + "title": "Introductory Financial Accounting", + "school": "Naveen Jindal School of Management", + "credit_hours": "3", + "class_level": "Undergraduate", + "activity_type": "Lecture", + "sections": ["67d07ee0c972c18731e23bea", "67d07ee0c972c18731e23bed"] + } +] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_relationship/professors.json b/uploader/testdata/uploader.go-tests/case_relationship/professors.json new file mode 100644 index 0000000..896f8f4 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_relationship/professors.json @@ -0,0 +1,18 @@ +[ + { + "_id": "67d07ee0c972c18731e23beb", + "first_name": "Naim Bugra", + "last_name": "Ozel", + "titles": ["Primary Instructor (50%)"], + "email": "nbo150030@utdallas.edu", + "sections": ["67d07ee0c972c18731e23bea", "67d07ee0c972c18731e23bed"] + }, + { + "_id": "67d07ee0c972c18731e23bec", + "first_name": "Jieying", + "last_name": "Zhang", + "titles": ["Primary Instructor (50%)"], + "email": "jxz146230@utdallas.edu", + "sections": ["67d07ee0c972c18731e23bea", "67d07ee0c972c18731e23bed"] + } +] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_relationship/sections.json b/uploader/testdata/uploader.go-tests/case_relationship/sections.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_relationship/sections.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_sorting/courses.json b/uploader/testdata/uploader.go-tests/case_sorting/courses.json new file mode 100644 index 0000000..f36b1e0 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_sorting/courses.json @@ -0,0 +1,38 @@ +[ + { + "_id": "67d07ee0c972c18731e23be9", + "subject_prefix": "ACCT", + "course_number": "2301", + "title": "Introductory Financial Accounting", + "school": "Naveen Jindal School of Management", + "credit_hours": "3", + "class_level": "Undergraduate", + "activity_type": "Lecture", + "catalog_year": "24", + "sections": [] + }, + { + "_id": "67d07ee0c972c18731e23bee", + "subject_prefix": "BA", + "course_number": "1320", + "title": "Business in a Global World", + "school": "Naveen Jindal School of Management", + "credit_hours": "3", + "class_level": "Undergraduate", + "activity_type": "Lecture", + "catalog_year": "23", + "sections": [] + }, + { + "_id": "67d07ee0c972c18731e23bf1", + "subject_prefix": "BIOL", + "course_number": "6111", + "title": "Graduate Research Presentation", + "school": "School of Natural Sciences and Mathematics", + "credit_hours": "1", + "class_level": "Graduate", + "activity_type": "Lecture", + "catalog_year": "24", + "sections": [] + } +] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_sorting/professors.json b/uploader/testdata/uploader.go-tests/case_sorting/professors.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_sorting/professors.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/uploader/testdata/uploader.go-tests/case_sorting/sections.json b/uploader/testdata/uploader.go-tests/case_sorting/sections.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/uploader/testdata/uploader.go-tests/case_sorting/sections.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/uploader/uploader_test.go b/uploader/uploader_test.go index b065c01..eec908c 100644 --- a/uploader/uploader_test.go +++ b/uploader/uploader_test.go @@ -41,6 +41,7 @@ func TestUpload(t *testing.T) { t.Run(tt.name, func(t *testing.T) { // This will panic when it tries to use the nil client, but that's fine for now // The goal is to test that the function calls what it should call + // TODO: Create different test cases defer func() { if r := recover(); r != nil { t.Logf("Expected panic when database operations are attempted: %v", r) From c4908c1e355bda3ba3bbb05c217c9f07a14b98ab Mon Sep 17 00:00:00 2001 From: Flavore669 Date: Thu, 6 Nov 2025 00:14:06 -0600 Subject: [PATCH 5/5] Finished --- .../case_basic/courses.json | 0 .../case_basic/professors.json | 0 .../case_basic/sections.json | 0 .../case_edge/courses.json | 0 .../case_edge/professors.json | 0 .../case_edge/sections.json | 0 .../case_multiple/courses.json | 0 .../case_multiple/professors.json | 0 .../case_multiple/sections.json | 0 .../case_relationship/courses.json | 0 .../case_relationship/professors.json | 0 .../case_relationship/sections.json | 0 .../case_sorting/courses.json | 0 .../case_sorting/professors.json | 0 .../case_sorting/sections.json | 0 uploader/uploader_test.go | 59 +++++++++++++++++-- 16 files changed, 54 insertions(+), 5 deletions(-) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_basic/courses.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_basic/professors.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_basic/sections.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_edge/courses.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_edge/professors.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_edge/sections.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_multiple/courses.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_multiple/professors.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_multiple/sections.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_relationship/courses.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_relationship/professors.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_relationship/sections.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_sorting/courses.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_sorting/professors.json (100%) rename uploader/testdata/{uploader.go-tests => uploader.go}/case_sorting/sections.json (100%) diff --git a/uploader/testdata/uploader.go-tests/case_basic/courses.json b/uploader/testdata/uploader.go/case_basic/courses.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_basic/courses.json rename to uploader/testdata/uploader.go/case_basic/courses.json diff --git a/uploader/testdata/uploader.go-tests/case_basic/professors.json b/uploader/testdata/uploader.go/case_basic/professors.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_basic/professors.json rename to uploader/testdata/uploader.go/case_basic/professors.json diff --git a/uploader/testdata/uploader.go-tests/case_basic/sections.json b/uploader/testdata/uploader.go/case_basic/sections.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_basic/sections.json rename to uploader/testdata/uploader.go/case_basic/sections.json diff --git a/uploader/testdata/uploader.go-tests/case_edge/courses.json b/uploader/testdata/uploader.go/case_edge/courses.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_edge/courses.json rename to uploader/testdata/uploader.go/case_edge/courses.json diff --git a/uploader/testdata/uploader.go-tests/case_edge/professors.json b/uploader/testdata/uploader.go/case_edge/professors.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_edge/professors.json rename to uploader/testdata/uploader.go/case_edge/professors.json diff --git a/uploader/testdata/uploader.go-tests/case_edge/sections.json b/uploader/testdata/uploader.go/case_edge/sections.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_edge/sections.json rename to uploader/testdata/uploader.go/case_edge/sections.json diff --git a/uploader/testdata/uploader.go-tests/case_multiple/courses.json b/uploader/testdata/uploader.go/case_multiple/courses.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_multiple/courses.json rename to uploader/testdata/uploader.go/case_multiple/courses.json diff --git a/uploader/testdata/uploader.go-tests/case_multiple/professors.json b/uploader/testdata/uploader.go/case_multiple/professors.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_multiple/professors.json rename to uploader/testdata/uploader.go/case_multiple/professors.json diff --git a/uploader/testdata/uploader.go-tests/case_multiple/sections.json b/uploader/testdata/uploader.go/case_multiple/sections.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_multiple/sections.json rename to uploader/testdata/uploader.go/case_multiple/sections.json diff --git a/uploader/testdata/uploader.go-tests/case_relationship/courses.json b/uploader/testdata/uploader.go/case_relationship/courses.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_relationship/courses.json rename to uploader/testdata/uploader.go/case_relationship/courses.json diff --git a/uploader/testdata/uploader.go-tests/case_relationship/professors.json b/uploader/testdata/uploader.go/case_relationship/professors.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_relationship/professors.json rename to uploader/testdata/uploader.go/case_relationship/professors.json diff --git a/uploader/testdata/uploader.go-tests/case_relationship/sections.json b/uploader/testdata/uploader.go/case_relationship/sections.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_relationship/sections.json rename to uploader/testdata/uploader.go/case_relationship/sections.json diff --git a/uploader/testdata/uploader.go-tests/case_sorting/courses.json b/uploader/testdata/uploader.go/case_sorting/courses.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_sorting/courses.json rename to uploader/testdata/uploader.go/case_sorting/courses.json diff --git a/uploader/testdata/uploader.go-tests/case_sorting/professors.json b/uploader/testdata/uploader.go/case_sorting/professors.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_sorting/professors.json rename to uploader/testdata/uploader.go/case_sorting/professors.json diff --git a/uploader/testdata/uploader.go-tests/case_sorting/sections.json b/uploader/testdata/uploader.go/case_sorting/sections.json similarity index 100% rename from uploader/testdata/uploader.go-tests/case_sorting/sections.json rename to uploader/testdata/uploader.go/case_sorting/sections.json diff --git a/uploader/uploader_test.go b/uploader/uploader_test.go index eec908c..c975f60 100644 --- a/uploader/uploader_test.go +++ b/uploader/uploader_test.go @@ -1,6 +1,7 @@ package uploader import ( + "path/filepath" "testing" "go.mongodb.org/mongo-driver/mongo" @@ -24,14 +25,62 @@ func TestUpload(t *testing.T) { staticOnly bool }{ { - name: "static only mode", - inDir: "./testdata", + name: "Case Basic: static only mode", + inDir: filepath.Join(".", "testdata", "case_basic"), replace: false, staticOnly: true, }, { - name: "full upload with replace", - inDir: "./testdata", + name: "Case Basic: full upload with replace", + inDir: filepath.Join(".", "testdata", "case_basic"), + replace: true, + staticOnly: false, + }, + { + name: "Case Edge: static only mode", + inDir: filepath.Join(".", "testdata", "case_edge"), + replace: false, + staticOnly: true, + }, + { + name: "Case Edge: full upload with replace", + inDir: filepath.Join(".", "testdata", "case_edge"), + replace: true, + staticOnly: false, + }, + { + name: "Case Multiple: static only mode", + inDir: filepath.Join(".", "testdata", "case_multiple"), + replace: false, + staticOnly: true, + }, + { + name: "Case Multiple: full upload with replace", + inDir: filepath.Join(".", "testdata", "case_multiple"), + replace: true, + staticOnly: false, + }, + { + name: "Case Relationship: static only mode", + inDir: filepath.Join(".", "testdata", "case_relationship"), + replace: false, + staticOnly: true, + }, + { + name: "Case Relationship: full upload with replace", + inDir: filepath.Join(".", "testdata", "case_relationship"), + replace: true, + staticOnly: false, + }, + { + name: "Case Sorting: static only mode", + inDir: filepath.Join(".", "testdata", "case_sorting"), + replace: false, + staticOnly: true, + }, + { + name: "Case Sorting: full upload with replace", + inDir: filepath.Join(".", "testdata", "case_sorting"), replace: true, staticOnly: false, }, @@ -41,7 +90,7 @@ func TestUpload(t *testing.T) { t.Run(tt.name, func(t *testing.T) { // This will panic when it tries to use the nil client, but that's fine for now // The goal is to test that the function calls what it should call - // TODO: Create different test cases + defer func() { if r := recover(); r != nil { t.Logf("Expected panic when database operations are attempted: %v", r)