diff options
author | Paul Duffin <paulduffin@google.com> | 2021-03-13 16:50:15 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2021-03-15 17:17:43 +0000 |
commit | aa6caa7fa8c3c662df82d3df950a8a6ecaf7477d (patch) | |
tree | c81df74c097fad774403db138f70bfd279f86969 /java/java_test.go | |
parent | 2ff6d1b6d2e9a5f3cc4e578f7470c9d8c4c483df (diff) |
Create sub tests for each test in TestJavaSdkLibraryEnforce
Bug: 182638834
Test: m nothing
Change-Id: I509b071ee4e470da45159b2174aae7acf1b0eb1a
Diffstat (limited to 'java/java_test.go')
-rw-r--r-- | java/java_test.go | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/java/java_test.go b/java/java_test.go index 356f8f58d..0a2237889 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -936,45 +936,55 @@ func TestJavaSdkLibraryEnforce(t *testing.T) { return config } + runTest := func(t *testing.T, info testConfigInfo, expectedErrorPattern string) { + t.Run(fmt.Sprintf("%#v", info), func(t *testing.T) { + if expectedErrorPattern == "" { + testJavaWithConfig(t, createTestConfig(info)) + } else { + testJavaErrorWithConfig(t, expectedErrorPattern, createTestConfig(info)) + } + }) + } + errorMessage := "is not allowed across the partitions" - testJavaWithConfig(t, createTestConfig(testConfigInfo{ + runTest(t, testConfigInfo{ libraryType: "java_library", fromPartition: "product", toPartition: "system", enforceVendorInterface: true, enforceProductInterface: true, enforceJavaSdkLibraryCheck: false, - })) + }, "") - testJavaWithConfig(t, createTestConfig(testConfigInfo{ + runTest(t, testConfigInfo{ libraryType: "java_library", fromPartition: "product", toPartition: "system", enforceVendorInterface: true, enforceProductInterface: false, enforceJavaSdkLibraryCheck: true, - })) + }, "") - testJavaErrorWithConfig(t, errorMessage, createTestConfig(testConfigInfo{ + runTest(t, testConfigInfo{ libraryType: "java_library", fromPartition: "product", toPartition: "system", enforceVendorInterface: true, enforceProductInterface: true, enforceJavaSdkLibraryCheck: true, - })) + }, errorMessage) - testJavaErrorWithConfig(t, errorMessage, createTestConfig(testConfigInfo{ + runTest(t, testConfigInfo{ libraryType: "java_library", fromPartition: "vendor", toPartition: "system", enforceVendorInterface: true, enforceProductInterface: true, enforceJavaSdkLibraryCheck: true, - })) + }, errorMessage) - testJavaWithConfig(t, createTestConfig(testConfigInfo{ + runTest(t, testConfigInfo{ libraryType: "java_library", fromPartition: "vendor", toPartition: "system", @@ -982,43 +992,43 @@ func TestJavaSdkLibraryEnforce(t *testing.T) { enforceProductInterface: true, enforceJavaSdkLibraryCheck: true, allowList: []string{"bar"}, - })) + }, "") - testJavaErrorWithConfig(t, errorMessage, createTestConfig(testConfigInfo{ + runTest(t, testConfigInfo{ libraryType: "java_library", fromPartition: "vendor", toPartition: "product", enforceVendorInterface: true, enforceProductInterface: true, enforceJavaSdkLibraryCheck: true, - })) + }, errorMessage) - testJavaWithConfig(t, createTestConfig(testConfigInfo{ + runTest(t, testConfigInfo{ libraryType: "java_sdk_library", fromPartition: "product", toPartition: "system", enforceVendorInterface: true, enforceProductInterface: true, enforceJavaSdkLibraryCheck: true, - })) + }, "") - testJavaWithConfig(t, createTestConfig(testConfigInfo{ + runTest(t, testConfigInfo{ libraryType: "java_sdk_library", fromPartition: "vendor", toPartition: "system", enforceVendorInterface: true, enforceProductInterface: true, enforceJavaSdkLibraryCheck: true, - })) + }, "") - testJavaWithConfig(t, createTestConfig(testConfigInfo{ + runTest(t, testConfigInfo{ libraryType: "java_sdk_library", fromPartition: "vendor", toPartition: "product", enforceVendorInterface: true, enforceProductInterface: true, enforceJavaSdkLibraryCheck: true, - })) + }, "") } func TestDefaults(t *testing.T) { |