Skip to content

Commit

Permalink
fix: Add ssdb environment preparation
Browse files Browse the repository at this point in the history
Change-Id: I8534e66786021ce4384c92a2a8d14aa50839a4da
  • Loading branch information
hudeng-go committed Oct 12, 2022
1 parent a1bb3e7 commit 1ffb45c
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions database/ssdb/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package ssdb_test

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"testing"

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

func setUpSsdb() error {
setUpStr := `
#!/bin/bash
if [ ! -e /tmp/ssdb-master/ssdb-master ]; then
mkdir -p /tmp/ssdb-master
wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip -O /tmp/ssdb-master/master.zip
cd /tmp/ssdb-master && unzip master && cd ssdb-master && make all
fi
cd /tmp/ssdb-master/ssdb-master && ./ssdb-server -d ssdb.conf -s restart
sleep 2`

tmpShell, err := ioutil.TempFile("/tmp", "ssdbSetup")
if err != nil {
return err
}
defer os.Remove(tmpShell.Name())

_, err = tmpShell.WriteString(setUpStr)
if err != nil {
return err
}

cmd := exec.Command("/bin/bash", tmpShell.Name())
fmt.Println(cmd.String())
output, err := cmd.Output()
fmt.Println(string(output))
if err != nil {
return err
}

return nil
}

func TestMain(m *testing.M) {
setUpSsdb()
m.Run()
}

type SSDBSuite struct {
cfg *conf.Config
db database.Storage
Expand Down

0 comments on commit 1ffb45c

Please sign in to comment.