@@ -55,6 +55,7 @@ func TestValidateCandidate(t *testing.T) {
5555 // Either err or invalid may be non-empty, but not both (both can be empty for a good plugin).
5656 err string
5757 invalid string
58+ expVer string
5859 }{
5960 // Invalid cases.
6061 {
@@ -95,12 +96,17 @@ func TestValidateCandidate(t *testing.T) {
9596 {
9697 name : "empty schemaversion" ,
9798 plugin : & fakeCandidate {path : goodPluginPath , exec : true , meta : `{}` },
98- invalid : `plugin SchemaVersion "" is not valid ` ,
99+ invalid : `plugin SchemaVersion version cannot be empty ` ,
99100 },
100101 {
101102 name : "invalid schemaversion" ,
102103 plugin : & fakeCandidate {path : goodPluginPath , exec : true , meta : `{"SchemaVersion": "xyzzy"}` },
103- invalid : `plugin SchemaVersion "xyzzy" is not valid` ,
104+ invalid : `plugin SchemaVersion "xyzzy" has wrong format: must be <major>.<minor>.<patch>` ,
105+ },
106+ {
107+ name : "invalid schemaversion major" ,
108+ plugin : & fakeCandidate {path : goodPluginPath , exec : true , meta : `{"SchemaVersion": "2.0.0"}` },
109+ invalid : `plugin SchemaVersion "2.0.0" is not supported: must be lower than 2.0.0` ,
104110 },
105111 {
106112 name : "no vendor" ,
@@ -117,11 +123,25 @@ func TestValidateCandidate(t *testing.T) {
117123 {
118124 name : "valid" ,
119125 plugin : & fakeCandidate {path : goodPluginPath , exec : true , meta : `{"SchemaVersion": "0.1.0", "Vendor": "e2e-testing"}` },
126+ expVer : "0.1.0" ,
120127 },
121128 {
122129 // Including the deprecated "experimental" field should not break processing.
123130 name : "with legacy experimental" ,
124131 plugin : & fakeCandidate {path : goodPluginPath , exec : true , meta : `{"SchemaVersion": "0.1.0", "Vendor": "e2e-testing", "Experimental": true}` },
132+ expVer : "0.1.0" ,
133+ },
134+ {
135+ // note that this may not be supported by older CLIs
136+ name : "new minor schema version" ,
137+ plugin : & fakeCandidate {path : goodPluginPath , exec : true , meta : `{"SchemaVersion": "0.2.0", "Vendor": "e2e-testing"}` },
138+ expVer : "0.2.0" ,
139+ },
140+ {
141+ // note that this may not be supported by older CLIs
142+ name : "new major schema version" ,
143+ plugin : & fakeCandidate {path : goodPluginPath , exec : true , meta : `{"SchemaVersion": "1.0.0", "Vendor": "e2e-testing"}` },
144+ expVer : "1.0.0" ,
125145 },
126146 } {
127147 t .Run (tc .name , func (t * testing.T ) {
@@ -136,7 +156,7 @@ func TestValidateCandidate(t *testing.T) {
136156 default :
137157 assert .NilError (t , err )
138158 assert .Equal (t , metadata .NamePrefix + p .Name , goodPluginName )
139- assert .Equal (t , p .SchemaVersion , "0.1.0" )
159+ assert .Equal (t , p .SchemaVersion , tc . expVer )
140160 assert .Equal (t , p .Vendor , "e2e-testing" )
141161 }
142162 })
0 commit comments