github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/api/version_test.go (about) 1 package api 2 3 import ( 4 "os" 5 "strconv" 6 "testing" 7 8 "github.com/go-resty/resty/v2" 9 "github.com/stretchr/testify/assert" 10 11 _ "github.com/NpoolPlatform/go-service-framework/pkg/version" 12 ) 13 14 func TestVersion(t *testing.T) { 15 if runByGithubAction, err := strconv.ParseBool(os.Getenv("RUN_BY_GITHUB_ACTION")); err == nil && runByGithubAction { 16 return 17 } 18 19 cli := resty.New() 20 resp, err := cli.R(). 21 Post("http://localhost:50570/v1/version") 22 if assert.Nil(t, err) { 23 assert.Equal(t, 200, resp.StatusCode()) 24 // we should compare body, but we cannot do here 25 // ver, err := version.GetVersion() 26 // assert.NotNil(t, err) 27 // assert.Equal(t, ver, string(resp.Body())) 28 } 29 }