[Groonga-commit] groonga/grnci at 560c015 [master] Add tests for DB.RubyLoad.

Back to archive index

Susumu Yata null+****@clear*****
Thu Sep 14 13:48:48 JST 2017


Susumu Yata	2017-09-14 13:48:48 +0900 (Thu, 14 Sep 2017)

  New Revision: 560c015c2d6765777ce05778f00c23fd71a12fb8
  https://github.com/groonga/grnci/commit/560c015c2d6765777ce05778f00c23fd71a12fb8

  Message:
    Add tests for DB.RubyLoad.
    
    Ref: #39

  Modified files:
    v2/libgrn/db_test.go

  Modified: v2/libgrn/db_test.go (+34 -0)
===================================================================
--- v2/libgrn/db_test.go    2017-09-13 18:30:20 +0900 (c6e04bb)
+++ v2/libgrn/db_test.go    2017-09-14 13:48:48 +0900 (778627f)
@@ -805,6 +805,40 @@ func TestRubyEvalInvalidScript(t *testing.T) {
 	}
 }
 
+func TestRubyLoad(t *testing.T) {
+	db, dir := makeDB(t)
+	defer removeDB(db, dir)
+
+	f, err := ioutil.TempFile("", "libgrn")
+	if err != nil {
+		t.Fatalf("ioutil.TempFile failed: %v", err)
+	}
+	defer os.Remove(f.Name())
+	defer f.Close()
+	if err := db.PluginRegister("ruby/load"); err != nil {
+		t.Skipf("db.PluginRegister failed: %v", err)
+	}
+	result, err := db.RubyLoad(f.Name())
+	if err != nil {
+		t.Fatalf("db.RubyLoad failed: %v", err)
+	}
+	if result != nil {
+		t.Fatalf("db.RubyLoad failed: result = %v, want = %v", result, nil)
+	}
+}
+
+func TestRubyLoadInvalidScript(t *testing.T) {
+	db, dir := makeDB(t)
+	defer removeDB(db, dir)
+
+	if err := db.PluginRegister("ruby/load"); err != nil {
+		t.Skipf("db.PluginRegister failed: %v", err)
+	}
+	if _, err := db.RubyLoad(""); err == nil {
+		t.Fatalf("db.RubyLoad wrongly succeeded")
+	}
+}
+
 func TestDBSchema(t *testing.T) {
 	db, dir := makeDB(t)
 	defer removeDB(db, dir)
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170914/ff3426c8/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index