Detect empty apex in ConfiguredJarList
Previously, ConfiguredJarList would accept an empty apex name, e.g. ":jar" which makes no sense as every apex has to have a non-empty name. This change makes an empty apex invalid. In order to improve the test coverage of the TestConfiguredJarList test this change also changes the implementation of CreateTestConfiguredJarList([]string) to marshal the supplied strings into a json list and then unmarshal into a ConfiguredJarList which more closely matches how it is used at runtime. Bug: 178361284 Test: m nothing Change-Id: I7dfec6b4cc1923aa99746e976da0393922ef0791
This commit is contained in:
@@ -100,6 +100,22 @@ func TestConfiguredJarList(t *testing.T) {
|
||||
assertStringEquals(t, "apex1:jarA", list1.String())
|
||||
})
|
||||
|
||||
t.Run("create invalid - missing apex", func(t *testing.T) {
|
||||
defer func() {
|
||||
err := recover().(error)
|
||||
assertStringEquals(t, "malformed (apex, jar) pair: 'jarA', expected format: <apex>:<jar>", err.Error())
|
||||
}()
|
||||
CreateTestConfiguredJarList([]string{"jarA"})
|
||||
})
|
||||
|
||||
t.Run("create invalid - empty apex", func(t *testing.T) {
|
||||
defer func() {
|
||||
err := recover().(error)
|
||||
assertStringEquals(t, "invalid apex '' in <apex>:<jar> pair ':jarA', expected format: <apex>:<jar>", err.Error())
|
||||
}()
|
||||
CreateTestConfiguredJarList([]string{":jarA"})
|
||||
})
|
||||
|
||||
list2 := list1.Append("apex2", "jarB")
|
||||
t.Run("append", func(t *testing.T) {
|
||||
assertStringEquals(t, "apex1:jarA,apex2:jarB", list2.String())
|
||||
|
Reference in New Issue
Block a user