vitess.io/vitess@v0.16.2/go/vt/servenv/buildinfo_test.go (about) 1 /* 2 Copyright 2021 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package servenv 18 19 import ( 20 "testing" 21 "time" 22 23 "github.com/stretchr/testify/assert" 24 ) 25 26 func TestVersionString(t *testing.T) { 27 now, _ := time.Parse(time.RFC1123, "Tue, 15 Sep 2020 12:04:10 UTC") 28 29 v := &versionInfo{ 30 buildHost: "host", 31 buildUser: "user", 32 buildTime: now.Unix(), 33 buildTimePretty: "time is now", 34 buildGitRev: "d54b87ca0be09b678bb4490060e8f23f890ddb92", 35 buildGitBranch: "gitBranch", 36 goVersion: "1.19.3", 37 goOS: "amiga", 38 goArch: "amd64", 39 version: "v1.2.3-SNAPSHOT", 40 } 41 42 assert.Equal(t, "Version: v1.2.3-SNAPSHOT (Git revision d54b87ca0be09b678bb4490060e8f23f890ddb92 branch 'gitBranch') built on time is now by user@host using 1.19.3 amiga/amd64", v.String()) 43 44 v.jenkinsBuildNumber = 422 45 46 assert.Equal(t, "Version: v1.2.3-SNAPSHOT (Jenkins build 422) (Git revision d54b87ca0be09b678bb4490060e8f23f890ddb92 branch 'gitBranch') built on time is now by user@host using 1.19.3 amiga/amd64", v.String()) 47 48 assert.Equal(t, "8.0.30-Vitess", v.MySQLVersion()) 49 }