github.com/openshift/dpu-operator@v0.0.0-20240502153209-3af840d137c2/dpu-cni/pkgs/cnihelper/cnihelper_test.go (about)

     1  package cnihelper_test
     2  
     3  import (
     4  	"github.com/containernetworking/cni/pkg/types"
     5  	g "github.com/onsi/ginkgo/v2"
     6  	"github.com/onsi/gomega"
     7  	o "github.com/onsi/gomega"
     8  	"github.com/openshift/dpu-operator/dpu-cni/pkgs/cnihelper"
     9  	"github.com/openshift/dpu-operator/dpu-cni/pkgs/cnitypes"
    10  )
    11  
    12  var _ = g.Describe("Cnihelper", func() {
    13  	g.Context("CNI Netconf Parser", func() {
    14  		g.When("DPU-CNI is specified", func() {
    15  			inputConfig := `
    16      		{
    17  				"cniVersion": "0.4.0",
    18  				"name": "dpu",
    19  				"type": "dpucni"
    20      		}`
    21  			expectedNetConf := &cnitypes.NetConf{
    22  				NetConf: types.NetConf{Name: "dpu", CNIVersion: "0.4.0", Type: "dpucni"},
    23  			}
    24  			g.It("should parse the Netconf correctly", func() {
    25  				netconf, err := cnihelper.ReadCNIConfig([]byte(inputConfig))
    26  				o.Expect(err).NotTo(o.HaveOccurred())
    27  				o.Expect(netconf).To(gomega.Equal(expectedNetConf))
    28  			})
    29  		})
    30  	})
    31  })