Commits

Greg Ward committed 4f0354b

plugins: more tests; use new testutils.NoError() function

  • Participants
  • Parent commits 981915f

Comments (0)

Files changed (3)

File src/fubsy/plugins/dummypython.go

 	return nil, NotAvailableError{"Python"}
 }
 
+func (self PythonPlugin) InstallBuiltins(builtins BuiltinList) error {
+	panic("dummy implementation")
+}
+
 func (self PythonPlugin) Run(content string) (types.ValueMap, error) {
 	panic("dummy implementation")
 }

File src/fubsy/plugins/meta_test.go

+package plugins
+
+import (
+	"testing"
+)
+
+func Test_init(t *testing.T) {
+	// test that metaFactory is correctly initialized
+	plugin, err := metaFactory["python2"]()
+	if err != nil {
+		if _, ok := err.(NotAvailableError); ok {
+			return
+		}
+		t.Fatalf("expected either nil error or NotAvailableError; "+
+			"got %T: %s",
+			err, err.Error())
+	}
+	_ = plugin.(PythonPlugin)
+}

File src/fubsy/plugins/python_test.go

 
 func Test_PythonPlugin_Run(t *testing.T) {
 	pp, err := NewPythonPlugin()
-	assert.Nil(t, err)
+	testutils.NoError(t, err)
 	values, err := pp.Run(`
 foo = ["abc", "def"]
 bar = "!".join(foo)`)
 	// PythonPlugin doesn't yet harvest Python values, so we cannot do
 	// anything to test values
 	_ = values
-	assert.Nil(t, err)
+	testutils.NoError(t, err)
 
 	values, err = pp.Run("foo = 1/0")
 	assert.Equal(t, "inline Python plugin raised an exception", err.Error())
 	builtins := StubBuiltinList{types.NewFixedFunction("println", 1, fn_println)}
 
 	pp, err := LoadMetaPlugin("python2", builtins)
-	assert.Nil(t, err)
+	testutils.NoError(t, err)
 
 	values, err := pp.Run(`
 fubsy.println("ding")
 `)
 	_ = values
 	expect := []string{"ding", "dong"}
-	assert.Nil(t, err)
+	testutils.NoError(t, err)
 	assert.Equal(t, expect, calls)
 }