github.com/john-lin/cni@v0.6.0-rc1.0.20170712150331-b69e640cc0e2/pkg/version/reconcile_test.go (about) 1 // Copyright 2016 CNI authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package version_test 16 17 import ( 18 "github.com/containernetworking/cni/pkg/version" 19 . "github.com/onsi/ginkgo" 20 . "github.com/onsi/gomega" 21 ) 22 23 var _ = Describe("Reconcile versions of net config with versions supported by plugins", func() { 24 var ( 25 reconciler *version.Reconciler 26 pluginInfo version.PluginInfo 27 ) 28 29 BeforeEach(func() { 30 reconciler = &version.Reconciler{} 31 pluginInfo = version.PluginSupports("1.2.3", "4.3.2") 32 }) 33 34 It("succeeds if the config version is supported by the plugin", func() { 35 err := reconciler.Check("4.3.2", pluginInfo) 36 Expect(err).NotTo(HaveOccurred()) 37 }) 38 39 Context("when the config version is not supported by the plugin", func() { 40 It("returns a helpful error", func() { 41 err := reconciler.Check("0.1.0", pluginInfo) 42 43 Expect(err).To(Equal(&version.ErrorIncompatible{ 44 Config: "0.1.0", 45 Supported: []string{"1.2.3", "4.3.2"}, 46 })) 47 48 Expect(err.Error()).To(Equal(`incompatible CNI versions: config is "0.1.0", plugin supports ["1.2.3" "4.3.2"]`)) 49 }) 50 }) 51 })