From 4f6c8aa18b69987501e92250ed314cd8cd8632e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Mon, 17 Sep 2018 11:52:42 +0200 Subject: [PATCH] Basic ooni unittest --- ooni_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ooni_test.go diff --git a/ooni_test.go b/ooni_test.go new file mode 100644 index 0000000..0e2df77 --- /dev/null +++ b/ooni_test.go @@ -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") + } +}