Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Remove redundant tests and unused test helpers

Manav Rathi731fa2670537
diff --git a/.github/checks/change-approval/test.mjs b/.github/checks/change-approval/test.mjs
index 42d8a332ff..a696e3fe0f 100644
--- a/.github/checks/change-approval/test.mjs
+++ b/.github/checks/change-approval/test.mjs
@@ -296,11 +296,11 @@ test("README deletions need approval in CI and local scans", (t) => {
}
});
-test("unchanged READMEs and ordinary Markdown deletions need no approval", (t) => {
+test("unchanged READMEs need no approval", (t) => {
const { stdout, output, summary } = scan(
t,
- { "README.md": "# Keep\n", "docs/old.md": "# Remove\n" },
- { "docs/old.md": null, "notes.txt": "Ordinary change\n" },
+ { "README.md": "# Keep\n" },
+ { "notes.txt": "Ordinary change\n" },
{ ci: true },
);
assert.equal(stdout, "");
@@ -308,15 +308,12 @@ test("unchanged READMEs and ordinary Markdown deletions need no approval", (t) =
assert.equal(summary, "No approval needed.\n");
});
-test("ordinary Markdown additions and edits need no approval", (t) => {
+test("README approval matches the beginning of the filename", (t) => {
for (const ci of [false, true]) {
const result = scan(
t,
- { "random.md": "# Original\n" },
+ {},
{
- "random.md": "# Updated\n",
- "docs/guide.markdown": "# Guide\n",
- "web/page.MDX": "# Page\n",
"README-assets/notes.md": "# Notes\n",
"docs/not-README.md": "# Other\n",
},
diff --git a/mobile/apps/photos/lib/services/photos_contacts_service.dart b/mobile/apps/photos/lib/services/photos_contacts_service.dart
index e182a54006..3dfe6f40c7 100644
--- a/mobile/apps/photos/lib/services/photos_contacts_service.dart
+++ b/mobile/apps/photos/lib/services/photos_contacts_service.dart
@@ -148,13 +148,8 @@ class PhotosContactsService {
}) => _store.ensureReady(baseUrl: baseUrl, userId: userId);
@visibleForTesting
- void debugHydrateContacts(
- List<contacts.ContactRecord> records, {
- bool markHydrated = false,
- }) => _store.debugHydrateContacts(records, markHydrated: markHydrated);
-
- @visibleForTesting
- void debugReset({bool notify = false}) => _store.clearSession(notify: notify);
+ void debugHydrateContacts(List<contacts.ContactRecord> records) =>
+ _store.debugHydrateContacts(records);
Future<void> close() => _store.close();
diff --git a/rust/crates/core/src/crypto/stream.rs b/rust/crates/core/src/crypto/stream.rs
index 4a05459df9..00395280e6 100644
--- a/rust/crates/core/src/crypto/stream.rs
+++ b/rust/crates/core/src/crypto/stream.rs
@@ -904,13 +904,6 @@ mod tests {
);
}
- #[test]
- fn test_constants_match_upstream() {
- assert_eq!(Header::BYTES, 24);
- assert_eq!(Key::BYTES, 32);
- assert_eq!(ABYTES, 17);
- }
-
#[test]
fn decrypting_writer_accepts_arbitrary_chunk_boundaries() {
let key = Key::generate();
diff --git a/rust/crates/ensu/src/config.rs b/rust/crates/ensu/src/config.rs
index 3e1903ab89..ce2b0f2501 100644
--- a/rust/crates/ensu/src/config.rs
+++ b/rust/crates/ensu/src/config.rs
@@ -354,10 +354,6 @@ mod tests {
#[test]
fn defaults_views_select_from_the_catalog() {
- let defaults = defaults();
- assert_eq!(defaults.mobile_default_model.id, "lfm-vl-1.6b");
- assert_eq!(defaults.desktop_default_model.id, "gemma-4-e4b-q4km");
-
let high_memory_mobile = resolve_model_policy(
ModelRuntimeSurface::Android,
Some(MOBILE_HIGH_MEMORY_THRESHOLD_BYTES),
diff --git a/rust/crates/ensu/src/config/knowledge.rs b/rust/crates/ensu/src/config/knowledge.rs
index 38a0757638..ab6da1b1fb 100644
--- a/rust/crates/ensu/src/config/knowledge.rs
+++ b/rust/crates/ensu/src/config/knowledge.rs
@@ -242,9 +242,6 @@ mod tests {
.map(|url| url.rsplit('/').next().unwrap().to_owned()),
KNOWLEDGE_ARTIFACT_FILENAMES.map(str::to_owned)
);
- assert!(urls.iter().all(|url| {
- url.contains("/resolve/a13b90e443dcdc1561ac777ea17ee6ed4703e35f/simplewiki/data/")
- }));
}
#[test]
@@ -252,7 +249,6 @@ mod tests {
let datasets = knowledge_datasets();
let embedding = knowledge_embedding_config();
- assert_eq!(datasets.len(), 3);
assert_eq!(
datasets
.iter()
@@ -261,24 +257,10 @@ mod tests {
.len(),
datasets.len()
);
- assert_eq!(datasets[0].stable_id, "simplewiki");
- assert_eq!(datasets[1].stable_id, "wikibooks");
- assert_eq!(datasets[2].stable_id, "fullwiki");
- assert!(
- datasets
- .iter()
- .all(|dataset| dataset.attribution.modification_notice == "Adapted by Ente")
- );
- assert_eq!(datasets[0].download_size_bytes, 167_849_446);
- assert_eq!(datasets[1].download_size_bytes, 202_595_475);
- assert_eq!(datasets[2].download_size_bytes, 363_051_703);
assert!(datasets.iter().all(|dataset| {
dataset.artifact_sizes.iter().sum::<u64>()
== u64::try_from(dataset.download_size_bytes).unwrap()
}));
- assert_eq!(datasets[0].relevance_threshold, 0.55);
- assert_eq!(datasets[1].relevance_threshold, 0.58);
- assert_eq!(datasets[2].relevance_threshold, 0.55);
assert!(datasets.iter().all(|dataset| {
dataset.artifact_sizes.len() == KNOWLEDGE_ARTIFACT_FILENAMES.len()
&& dataset.artifact_sha256.len() == KNOWLEDGE_ARTIFACT_FILENAMES.len()
@@ -288,8 +270,6 @@ mod tests {
.all(|sha256| sha256.len() == 64)
}));
assert_eq!(embedding.model_sha256.len(), 64);
- assert_eq!(knowledge_index_contract().source_dim, 768);
- assert_eq!(knowledge_index_contract().dim, 512);
assert!(datasets.iter().all(|dataset| {
is_path_safe_component(&dataset.stable_id)
&& is_path_safe_component(&dataset.current_download_identity)
diff --git a/rust/crates/ml/src/assets.rs b/rust/crates/ml/src/assets.rs
index 6672d41838..d548a01616 100644
--- a/rust/crates/ml/src/assets.rs
+++ b/rust/crates/ml/src/assets.rs
@@ -315,17 +315,6 @@ mod tests {
}
}
- #[test]
- fn retired_keys_are_not_in_the_catalog() {
- for key in RETIRED_MODEL_KEYS {
- assert!(
- Model::ALL
- .iter()
- .all(|model| model_asset_spec(*model).key != *key)
- );
- }
- }
-
#[test]
fn test_model_pins_match_the_catalog() {
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
diff --git a/rust/crates/ml/src/diagnostics.rs b/rust/crates/ml/src/diagnostics.rs
index fa8a38fe6d..06a0078f9a 100644
--- a/rust/crates/ml/src/diagnostics.rs
+++ b/rust/crates/ml/src/diagnostics.rs
@@ -488,14 +488,4 @@ mod tests {
Some(Duration::from_secs(30))
);
}
-
- #[test]
- fn error_kinds_are_stable_for_log_filtering() {
- assert_eq!(error_kind(&MlError::Decode("bad image".into())), "decode");
- assert_eq!(error_kind(&MlError::Ort("failed".into())), "ort");
- assert_eq!(
- error_kind(&MlError::CorruptModel("model.onnx".into())),
- "corrupt_model"
- );
- }
}
diff --git a/rust/crates/ml/src/models.rs b/rust/crates/ml/src/models.rs
index f47ca7762a..ca613edd95 100644
--- a/rust/crates/ml/src/models.rs
+++ b/rust/crates/ml/src/models.rs
@@ -172,61 +172,9 @@ mod tests {
use super::*;
#[test]
- fn model_order_and_labels_are_stable() {
- let expected = [
- (
- Model::FaceDetection,
- "faceDetectionModelPath",
- "face-detection",
- ),
- (
- Model::FaceEmbedding,
- "faceEmbeddingModelPath",
- "face-embedding",
- ),
- (Model::ClipImage, "clipImageModelPath", "clip-image"),
- (Model::ClipText, "clipTextModelPath", "clip-text"),
- (
- Model::PetFaceDetection,
- "petFaceDetectionModelPath",
- "pet-face-detection",
- ),
- (
- Model::PetFaceEmbeddingDog,
- "petFaceEmbeddingDogModelPath",
- "pet-face-embedding-dog",
- ),
- (
- Model::PetFaceEmbeddingCat,
- "petFaceEmbeddingCatModelPath",
- "pet-face-embedding-cat",
- ),
- (
- Model::PetBodyDetection,
- "petBodyDetectionModelPath",
- "pet-body-detection",
- ),
- (
- Model::PetBodyEmbeddingDog,
- "petBodyEmbeddingDogModelPath",
- "pet-body-embedding-dog",
- ),
- (
- Model::PetBodyEmbeddingCat,
- "petBodyEmbeddingCatModelPath",
- "pet-body-embedding-cat",
- ),
- ];
- let mut path_labels = HashSet::new();
- let mut namespaces = HashSet::new();
-
- for (index, (model, path_label, namespace)) in expected.into_iter().enumerate() {
- assert_eq!(Model::ALL[index], model);
+ fn model_order_matches_indexes() {
+ for (index, model) in Model::ALL.into_iter().enumerate() {
assert_eq!(model.index(), index);
- assert_eq!(model.path_label(), path_label);
- assert_eq!(model.namespace(), namespace);
- assert!(path_labels.insert(path_label));
- assert!(namespaces.insert(namespace));
}
}
diff --git a/rust/crates/ml/src/ocr/assets.rs b/rust/crates/ml/src/ocr/assets.rs
index 7558dc7b36..e6f087b069 100644
--- a/rust/crates/ml/src/ocr/assets.rs
+++ b/rust/crates/ml/src/ocr/assets.rs
@@ -181,26 +181,6 @@ mod tests {
assert!(!is_detector_downloaded(&store));
}
- #[test]
- fn legacy_models_do_not_satisfy_the_optimized_catalog() {
- let root = tempfile::tempdir().unwrap();
- let store = AssetStore::new(root.path());
- for (model, legacy_key) in [
- (&DETECTION, "ppocrv5_det"),
- (&CLASSIFICATION, "ppocrv5_cls"),
- (&RECOGNITION, "ppocrv5_rec"),
- ] {
- let legacy = OcrModelFile {
- key: legacy_key,
- ..*model
- };
- cache_model(&store, &legacy);
- assert!(!store.is_downloaded(&model.asset()));
- assert_ne!(model.path(&store), legacy.path(&store));
- }
- assert!(!is_detector_downloaded(&store));
- }
-
#[tokio::test]
async fn cached_detector_can_be_prepared_without_recognition_models() {
let root = tempfile::tempdir().unwrap();
diff --git a/rust/crates/ml/src/runtime.rs b/rust/crates/ml/src/runtime.rs
index d9cd3b19a9..42909dabb2 100644
--- a/rust/crates/ml/src/runtime.rs
+++ b/rust/crates/ml/src/runtime.rs
@@ -351,20 +351,6 @@ mod tests {
assert_eq!(model_runtime.snapshot(), unloaded_snapshot(second_path));
}
- #[test]
- fn model_execution_modes_match_platform_policy() {
- let accelerated = [Model::FaceDetection, Model::FaceEmbedding, Model::ClipImage];
-
- for model in Model::ALL {
- let expected = if accelerated.contains(&model) {
- onnx::ExecutionMode::PlatformDefault
- } else {
- onnx::ExecutionMode::CpuOnly
- };
- assert_eq!(default_execution_mode(model), expected, "{model:?}");
- }
- }
-
fn unloaded_snapshot(path: &str) -> ModelRuntimeSnapshot {
ModelRuntimeSnapshot {
path: path.to_string(),
diff --git a/server/pkg/api/user_test.go b/server/pkg/api/user_test.go
index ec48c6e50a..709640aed4 100644
--- a/server/pkg/api/user_test.go
+++ b/server/pkg/api/user_test.go
@@ -58,32 +58,6 @@ func TestGetPublicKeyHandlerUsesEmailLookup(t *testing.T) {
}
}
-func TestGetPublicKeyHandlerDoesNotLookupByUserID(t *testing.T) {
- handler, db := setupUserHandlerTest(t)
- requesterUserID := testutil.InsertUser(t, db, testutil.UserFixture{
- UserID: 101,
- Email: "[email protected]",
- CreationTime: 1,
- })
- targetUserID := testutil.InsertUser(t, db, testutil.UserFixture{
- UserID: 102,
- Email: "[email protected]",
- CreationTime: 1,
- })
- setPublicKeyTestAttributes(t, handler, targetUserID)
-
- recorder := httptest.NewRecorder()
- req := httptest.NewRequest(http.MethodGet, "/users/public-key?userID=102", nil)
- req.Header.Set("X-Auth-User-ID", strconv.FormatInt(requesterUserID, 10))
- router := gin.New()
- router.GET("/users/public-key", handler.GetPublicKey)
- router.ServeHTTP(recorder, req)
-
- if recorder.Code != http.StatusNotFound {
- t.Fatalf("unexpected status code: got %d want %d; body=%s", recorder.Code, http.StatusNotFound, recorder.Body.String())
- }
-}
-
func TestGetPublicKeysHandler(t *testing.T) {
handler, db := setupUserHandlerTest(t)
requesterUserID := testutil.InsertUser(t, db, testutil.UserFixture{
diff --git a/web/apps/locker/tests/required-fields.test.ts b/web/apps/locker/tests/required-fields.test.ts
index 0d710bfbe8..8a051c9212 100644
--- a/web/apps/locker/tests/required-fields.test.ts
+++ b/web/apps/locker/tests/required-fields.test.ts
@@ -1,18 +1,5 @@
import { expect, test } from "vitest";
-import {
- getRequiredFields,
- itemFormDataForSave,
-} from "../src/components/create-item/item-form-fields-utils";
-
-test.each([
- ["note", ["content"]],
- ["accountCredential", ["name"]],
- ["physicalRecord", ["name"]],
- ["emergencyContact", ["name", "contactDetails"]],
- ["file", ["name"]],
-] as const)("required fields for %s", (type, expected) => {
- expect(getRequiredFields(type)).toEqual(expected);
-});
+import { itemFormDataForSave } from "../src/components/create-item/item-form-fields-utils";
test("content-only notes derive a title from the first five words", () => {
expect(