blob: d74738b5e8a63ba3806d4a90b3efd82ff11bb7e7 [file] [log] [blame]
package main_test
import (
"os"
"plugin"
"testing"
)
const HelloWorld = "Hello, world!"
func TestPluginCreated(t *testing.T) {
_, err := os.Stat("plugin.so")
if err != nil {
t.Error(err)
}
}
func TestPluginWorks(t *testing.T) {
p, err := plugin.Open("plugin.so")
if err != nil {
t.Error(err)
}
f, err := p.Lookup("Hi")
if err != nil {
t.Error(err)
}
helloWorld := f.(func() string)()
if helloWorld != HelloWorld {
t.Errorf("expected %#v, got %#v", HelloWorld, helloWorld)
}
}