github.heygears.com/openimsdk/tools@v0.0.49/version/version_test.go (about)

     1  package version
     2  
     3  import (
     4  	"runtime"
     5  	"strings"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  // TestGet verifies that the Get function returns expected fields correctly set.
    12  func TestGet(t *testing.T) {
    13  	v := Get()
    14  
    15  	assert.NotEmpty(t, v.GoVersion, "GoVersion should not be empty")
    16  	assert.NotEmpty(t, v.Compiler, "Compiler should not be empty")
    17  	assert.NotEmpty(t, v.Platform, "Platform should not be empty")
    18  	assert.True(t, strings.Contains(v.Platform, runtime.GOOS), "Platform should contain runtime.GOOS")
    19  	assert.True(t, strings.Contains(v.Platform, runtime.GOARCH), "Platform should contain runtime.GOARCH")
    20  }
    21  
    22  // TestGetSingleVersion verifies that the GetSingleVersion function returns the gitVersion.
    23  func TestGetSingleVersion(t *testing.T) {
    24  	version := GetSingleVersion()
    25  	assert.Equal(t, gitVersion, version, "gitVersion should match the global gitVersion variable")
    26  }