github.com/joey-fossa/fossa-cli@v0.7.34-0.20190708193710-569f1e8679f0/cmd/fossa/version/version_test.go (about) 1 package version 2 3 import ( 4 "strings" 5 "testing" 6 ) 7 8 type versions struct { 9 name string 10 11 buildType string 12 version string 13 commit string 14 goversion string 15 } 16 17 var noLdFlags = versions{ 18 name: "NoLdFlags", 19 20 buildType: "", 21 version: "", 22 commit: "", 23 goversion: "", 24 } 25 26 var dev = versions{ 27 name: "Development", 28 29 buildType: "development", 30 version: "some-branch-name", 31 commit: "12345abcdef", 32 goversion: "go version go1.10.2 linux/amd64", 33 } 34 35 var prod = versions{ 36 name: "Release", 37 38 buildType: "release", 39 version: "v1.2.3-validsemanticversion", 40 commit: "67890foobar", 41 goversion: "go version go1.10.2 linux/amd64", 42 } 43 44 func TestShortStringHasNoSpaces(t *testing.T) { 45 testCases := []versions{ 46 noLdFlags, dev, prod, 47 } 48 for _, tc := range testCases { 49 t.Run(tc.name, func(t *testing.T) { 50 if s := ShortString(); len(strings.Fields(s)) > 1 { 51 t.Errorf("ShortString() had whitespace: %#v", s) 52 } 53 }) 54 } 55 }