github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/datastore/crdb/version_test.go (about) 1 package crdb 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func TestParseVersionString(t *testing.T) { 10 testCases := []struct { 11 versionStr string 12 expected crdbVersion 13 expectError bool 14 }{ 15 { 16 "CockroachDB CCL v22.2.0-rc.3 (aarch64-unknown-linux-gnu, built 2022/11/21 17:44:44, go1.19.1)", 17 crdbVersion{0, 22, 2, 0}, 18 false, 19 }, 20 { 21 "CockroachDB CCL v22.2.0 (aarch64-unknown-linux-gnu, built 2022/12/05 17:11:12, go1.19.1)", 22 crdbVersion{0, 22, 2, 0}, 23 false, 24 }, 25 { 26 "CockroachDB CCL v22.1.4 (x86_64-pc-linux-gnu, built 2022/07/19 17:09:48, go1.17.11)", 27 crdbVersion{0, 22, 1, 4}, 28 false, 29 }, 30 { 31 "CockroachDB CCL", 32 crdbVersion{}, 33 true, 34 }, 35 { 36 "CockroachDB CCL va.2.0-rc.3 (aarch64-unknown-linux-gnu, built 2022/11/21 17:44:44, go1.19.1)", 37 crdbVersion{}, 38 true, 39 }, 40 } 41 42 for _, tc := range testCases { 43 tc := tc 44 t.Run(tc.versionStr, func(t *testing.T) { 45 var version crdbVersion 46 err := parseVersionStringInto(tc.versionStr, &version) 47 if tc.expectError { 48 require.Error(t, err) 49 } else { 50 require.NoError(t, err) 51 require.Equal(t, tc.expected, version) 52 } 53 }) 54 } 55 }