github.com/slspeek/camlistore_namedsearch@v0.0.0-20140519202248-ed6f70f7721a/pkg/index/mysql_test.go (about) 1 /* 2 Copyright 2012 The Camlistore 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 index_test 18 19 import ( 20 "testing" 21 22 "camlistore.org/pkg/index/indextest" 23 "camlistore.org/pkg/jsonconfig" 24 "camlistore.org/pkg/osutil" 25 "camlistore.org/pkg/sorted" 26 "camlistore.org/pkg/sorted/kvtest" 27 _ "camlistore.org/pkg/sorted/mysql" 28 "camlistore.org/pkg/test/dockertest" 29 ) 30 31 func newMySQLSorted(t *testing.T) (kv sorted.KeyValue, clean func()) { 32 dbname := "camlitest_" + osutil.Username() 33 containerID, ip := dockertest.SetupMySQLContainer(t, dbname) 34 35 kv, err := sorted.NewKeyValue(jsonconfig.Obj{ 36 "type": "mysql", 37 "host": ip + ":3306", 38 "database": dbname, 39 "user": dockertest.MySQLUsername, 40 "password": dockertest.MySQLPassword, 41 }) 42 if err != nil { 43 containerID.KillRemove(t) 44 t.Fatal(err) 45 } 46 return kv, func() { 47 kv.Close() 48 containerID.KillRemove(t) 49 } 50 } 51 52 func TestSorted_MySQL(t *testing.T) { 53 kv, clean := newMySQLSorted(t) 54 defer clean() 55 kvtest.TestSorted(t, kv) 56 } 57 58 func TestIndex_MySQL(t *testing.T) { 59 indexTest(t, newMySQLSorted, indextest.Index) 60 } 61 62 func TestPathsOfSignerTarget_MySQL(t *testing.T) { 63 indexTest(t, newMySQLSorted, indextest.PathsOfSignerTarget) 64 } 65 66 func TestFiles_MySQL(t *testing.T) { 67 indexTest(t, newMySQLSorted, indextest.Files) 68 } 69 70 func TestEdgesTo_MySQL(t *testing.T) { 71 indexTest(t, newMySQLSorted, indextest.EdgesTo) 72 } 73 74 func TestDelete_MySQL(t *testing.T) { 75 indexTest(t, newMySQLSorted, indextest.Delete) 76 }