Skip to content

Commit 1ffb45c

Browse files
committed
fix: Add ssdb environment preparation
Change-Id: I8534e66786021ce4384c92a2a8d14aa50839a4da
1 parent a1bb3e7 commit 1ffb45c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

database/ssdb/database_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package ssdb_test
22

33
import (
44
"fmt"
5+
"io/ioutil"
6+
"os"
7+
"os/exec"
58
"testing"
69

710
"github.com/aptly-dev/aptly/database"
@@ -15,6 +18,44 @@ func Test(t *testing.T) {
1518
TestingT(t)
1619
}
1720

21+
func setUpSsdb() error {
22+
setUpStr := `
23+
#!/bin/bash
24+
if [ ! -e /tmp/ssdb-master/ssdb-master ]; then
25+
mkdir -p /tmp/ssdb-master
26+
wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip -O /tmp/ssdb-master/master.zip
27+
cd /tmp/ssdb-master && unzip master && cd ssdb-master && make all
28+
fi
29+
cd /tmp/ssdb-master/ssdb-master && ./ssdb-server -d ssdb.conf -s restart
30+
sleep 2`
31+
32+
tmpShell, err := ioutil.TempFile("/tmp", "ssdbSetup")
33+
if err != nil {
34+
return err
35+
}
36+
defer os.Remove(tmpShell.Name())
37+
38+
_, err = tmpShell.WriteString(setUpStr)
39+
if err != nil {
40+
return err
41+
}
42+
43+
cmd := exec.Command("/bin/bash", tmpShell.Name())
44+
fmt.Println(cmd.String())
45+
output, err := cmd.Output()
46+
fmt.Println(string(output))
47+
if err != nil {
48+
return err
49+
}
50+
51+
return nil
52+
}
53+
54+
func TestMain(m *testing.M) {
55+
setUpSsdb()
56+
m.Run()
57+
}
58+
1859
type SSDBSuite struct {
1960
cfg *conf.Config
2061
db database.Storage

0 commit comments

Comments
 (0)