Add tests for main package, manager, and various components
- Introduced unit tests for the main package to ensure compilation. - Added tests for the manager, including validation of upload sessions and handling of Blender binary paths. - Implemented tests for job token generation and validation, ensuring security and integrity. - Created tests for configuration management and database schema to verify functionality. - Added tests for logger and runner components to enhance overall test coverage and reliability.
This commit is contained in:
30
web/embed_test.go
Normal file
30
web/embed_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetStaticFileSystem_NonNil(t *testing.T) {
|
||||
fs := GetStaticFileSystem()
|
||||
if fs == nil {
|
||||
t.Fatal("static filesystem should not be nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStaticHandler_ServesWithoutPanic(t *testing.T) {
|
||||
h := StaticHandler()
|
||||
rr := httptest.NewRecorder()
|
||||
req := httptest.NewRequest("GET", "/assets/does-not-exist.txt", nil)
|
||||
h.ServeHTTP(rr, req)
|
||||
if rr.Code == 0 {
|
||||
t.Fatal("handler should write a status code")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetTemplateFS_NonNil(t *testing.T) {
|
||||
if GetTemplateFS() == nil {
|
||||
t.Fatal("template fs should not be nil")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,11 +169,27 @@
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
throw new Error(data.error || "Job creation failed");
|
||||
const err = new Error(data.error || "Job creation failed");
|
||||
if (data && typeof data.code === "string") {
|
||||
err.code = data.code;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function resetToUploadStep(message) {
|
||||
sessionID = "";
|
||||
clearInterval(pollTimer);
|
||||
setUploadBusy(false);
|
||||
mainBlendWrapper.classList.add("hidden");
|
||||
metadataPreview.innerHTML = "";
|
||||
configSection.classList.add("hidden");
|
||||
setStep(1);
|
||||
showStatus("Please upload the file again.");
|
||||
showError(message);
|
||||
}
|
||||
|
||||
async function runSubmission(mainBlendFile) {
|
||||
showError("");
|
||||
setStep(1);
|
||||
@@ -277,6 +293,14 @@
|
||||
showError("");
|
||||
await submitJobConfig();
|
||||
} catch (err) {
|
||||
if (err && err.code === "UPLOAD_SESSION_EXPIRED") {
|
||||
resetToUploadStep(err.message || "Upload session expired. Please upload the file again.");
|
||||
return;
|
||||
}
|
||||
if (err && err.code === "UPLOAD_SESSION_NOT_READY") {
|
||||
showError(err.message || "Upload session is still processing. Please wait and try again.");
|
||||
return;
|
||||
}
|
||||
showError(err.message || "Failed to create job");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user