github.com/verrazzano/verrazzano@v1.7.1/application-operator/controllers/controller_utils_test.go (about)

     1  // Copyright (c) 2020, 2021, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  package controllers
     5  
     6  import (
     7  	"testing"
     8  
     9  	asserts "github.com/stretchr/testify/assert"
    10  )
    11  
    12  // TestConvertAPIVersionToGroupAndVersion tests multiple use cases for parsing APIVersion
    13  func TestConvertAPIVersionToGroupAndVersion(t *testing.T) {
    14  	assert := asserts.New(t)
    15  	var g, v string
    16  
    17  	// GIVEN a normal group/version string
    18  	// WHEN it is parsed into group and version parts
    19  	// THEN ensure the parts are correct.
    20  	g, v = ConvertAPIVersionToGroupAndVersion("group/version")
    21  	assert.Equal("group", g)
    22  	assert.Equal("version", v)
    23  
    24  	// GIVEN a normal group/version string with no group.
    25  	// WHEN it is parsed into group and version parts
    26  	// THEN ensure the group is the empty string and the version is correct.
    27  	// This is the case for older standard kubernetes core resources.
    28  	g, v = ConvertAPIVersionToGroupAndVersion("/version")
    29  	assert.Equal("", g)
    30  	assert.Equal("version", v)
    31  
    32  	// GIVEN a normal group/version string with no group.
    33  	// WHEN it is parsed into group and version parts
    34  	// THEN ensure the group is the empty string and the version is correct.
    35  	// This is the case for older standard kubernetes core resources.
    36  	g, v = ConvertAPIVersionToGroupAndVersion("version")
    37  	assert.Equal("", g)
    38  	assert.Equal("version", v)
    39  }