Make container mandatory in aconfig_declarations.

Bug: 330354107
Test: Unit test and CI.

Ignore-AOSP-First: It is easier to detect all the missing ones in internal
master.

Change-Id: I4ab4271c67a35d0fdcc0b57c27260e29fb7dea56
diff --git a/aconfig/aconfig_declarations_test.go b/aconfig/aconfig_declarations_test.go
index 5201fed..c37274c 100644
--- a/aconfig/aconfig_declarations_test.go
+++ b/aconfig/aconfig_declarations_test.go
@@ -88,19 +88,49 @@
 	android.AssertStringEquals(t, "rule must contain container", rule.Args["container"], "--container com.android.foo")
 }
 
-func TestAconfigDeclarationsWithoutContainer(t *testing.T) {
-	bp := `
-		aconfig_declarations {
-			name: "module_name",
-			package: "com.example.package",
-			srcs: [
-				"foo.aconfig",
-			],
-		}
-	`
-	result := runTest(t, android.FixtureExpectsNoErrors, bp)
-
-	module := result.ModuleForTests("module_name", "")
-	rule := module.Rule("aconfig")
-	android.AssertIntEquals(t, "rule must not contain container", len(rule.Args["container"]), 0)
+func TestMandatoryProperties(t *testing.T) {
+	testCases := []struct {
+		name          string
+		expectedError string
+		bp            string
+	}{
+		{
+			name: "Srcs missing from aconfig_declarations",
+			bp: `
+				aconfig_declarations {
+					name: "my_aconfig_declarations_foo",
+					package: "com.example.package",
+					container: "otherapex",
+				}`,
+			expectedError: `missing source files`,
+		},
+		{
+			name: "Package missing from aconfig_declarations",
+			bp: `
+				aconfig_declarations {
+					name: "my_aconfig_declarations_foo",
+					container: "otherapex",
+					srcs: ["foo.aconfig"],
+				}`,
+			expectedError: `missing package property`,
+		},
+		{
+			name: "Container missing from aconfig_declarations",
+			bp: `
+				aconfig_declarations {
+					name: "my_aconfig_declarations_foo",
+					package: "com.example.package",
+					srcs: ["foo.aconfig"],
+				}`,
+			expectedError: `missing container property`,
+		},
+	}
+	for _, test := range testCases {
+		t.Run(test.name, func(t *testing.T) {
+			errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(test.expectedError)
+			android.GroupFixturePreparers(PrepareForTestWithAconfigBuildComponents).
+				ExtendWithErrorHandler(errorHandler).
+				RunTestWithBp(t, test.bp)
+		})
+	}
 }