Basic ooni unittest
This commit is contained in:
parent
bd6a5acf5b
commit
4f6c8aa18b
27
ooni_test.go
Normal file
27
ooni_test.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package ooni
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInit(t *testing.T) {
|
||||
ooniHome, err := ioutil.TempDir("", "oonihome")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(ooniHome)
|
||||
|
||||
ctx := NewContext("", ooniHome)
|
||||
if err := ctx.Init(); err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal("failed to init the context")
|
||||
}
|
||||
|
||||
configPath := path.Join(ooniHome, "config.json")
|
||||
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
||||
t.Fatal("config file was not created")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user