github.com/mmatczuk/gohan@v0.0.0-20170206152520-30e45d9bdb69/extension/extension_suite_test.go (about) 1 // Copyright (C) 2015 NTT Innovation Institute, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 // implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 package extension_test 17 18 import ( 19 "os" 20 "testing" 21 22 "github.com/cloudwan/gohan/db" 23 24 . "github.com/onsi/ginkgo" 25 . "github.com/onsi/gomega" 26 "github.com/cloudwan/gohan/sync/etcdv3" 27 "time" 28 ) 29 30 var ( 31 testDB1 db.DB 32 testDB2 db.DB 33 testSync *etcdv3.Sync 34 ) 35 36 func TestExtension(t *testing.T) { 37 RegisterFailHandler(Fail) 38 RunSpecs(t, "Extension Suite") 39 } 40 41 var _ = Describe("Suite set up and tear down", func() { 42 const ( 43 testDBFile1 = "./extensionTest1.db" 44 testDBFile2 = "./extensionTest2.db" 45 testSyncEndpoint = "localhost:2379" 46 ) 47 48 var _ = BeforeSuite(func() { 49 var err error 50 testDB1, err = db.ConnectDB("sqlite3", testDBFile1, db.DefaultMaxOpenConn) 51 Expect(err).ToNot(HaveOccurred(), "Failed to connect database.") 52 testDB2, err = db.ConnectDB("sqlite3", testDBFile2, db.DefaultMaxOpenConn) 53 Expect(err).ToNot(HaveOccurred(), "Failed to connect database.") 54 testSync, err = etcdv3.NewSync([]string{testSyncEndpoint}, time.Second) 55 Expect(err).ToNot(HaveOccurred(), "Failed to connect to etcd") 56 }) 57 58 var _ = AfterSuite(func() { 59 testSync.Close() 60 os.Remove(testDBFile1) 61 os.Remove(testDBFile2) 62 }) 63 })